Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > No Value: DropDownlist in EditItemTemplate Gridview Problem

Reply
Thread Tools

No Value: DropDownlist in EditItemTemplate Gridview Problem

 
 
den 2005
Guest
Posts: n/a
 
      10-11-2006
Hi everybody,

I created a Gridview with a TemplateField and there is Label control in
ItemTemplate and a DropdownList control in EditItemTemplate, I was to
displayed them ok when I click the Edit Command button. But when I about to
get the value of this template field I get an empty string value. I check the
following the local dtFiles has data and the cells are visible at stage right
before foreach GridViewRow gr in gdvFiles.Rows) loop. Can anyone tell what is
missing or I went wrong? Thanks

Code:
<asp:GridView ID="gdvFiles" runat="server"
AutoGenerateColumns="False" ShowHeader="False" Width="649px"
OnRowEditing="gdvFiles_RowEditing" OnRowUpdating="gdvFiles_RowUpdating">
.....
<asp:TemplateField HeaderText="FileType"
ShowHeader="False" Visible="False">
<HeaderStyle Width="30px"
HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle Width="30px" HorizontalAlign="Center"
VerticalAlign="Middle" />
<ItemTemplate>

<asp:Label ID="lblFileType" runat="server"
Text='<%# Eval("FileType") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlType"
runat="server" DataSource='<%# LoadFileTypes() %>'
DataTextField="FileTypeCode" DataValueField="FileTypeCode"
OnSelectedIndexChanged="ddlType_SelectedIndexChanged"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
.....
</asp:GridView>


I need to process the values of this Gridview cells inside in this method:
private void UpdateRelatedFiles(Int32 ideaId, Int32 userId, Int32 langId)
{
....
RetrieveTempData();
LoadFileGrid(true);

foreach (GridViewRow gr in gdvFiles.Rows)
{
id = ((HtmlInputCheckBox)gr.Cells[0].Controls[1]).Value;
fileId = Convert.ToInt32(id);
fname = gr.Cells[1].Text;
ftype = gr.Cells[2].Text;<<<--- STRING VALUE IS EMPTY
fsize = gr.Cells[3].Text;
fpath = gr.Cells[4].Text;
....
}
....
}

private void RetrieveTempData()
{
....
dtFiles = GetTempData("Files");
....
}

private DataTable GetTempData(string choice)
{
try
{
if (...)
....
else if (choice == "Files")
return (DataTable) Session["dtFiles"];
}
catch
{
return null;
}
return null;
}

private void LoadFileGrid(bool colVisible)
{
if (dtFiles != null)
{
DataTable dtLocal = GetTempData("Files");
if (dtLocal != null)
gridview1.DataSource = dtLocal;
else
gridview1.DataSource = dtFiles;
ChangeGridviewColumnVisibility(colVisible, gridview1, "Files",
true);
gridview1.DataBind();
}
}

private void ChangeGridviewColumnVisibility(bool visible, GridView
gdvLocal, string section, bool isUpdate)
{

for (int x = 0; x < gdvLocal.Columns.Count; x++)
{
if (visible)
{
if (gdvLocal.Columns[x].HeaderText == "DocumentID" &&
isUpdate)
gdvLocal.Columns[x].Visible = visible;
else
gdvLocal.Columns[x].Visible = visible;
}
else if (!visible)
{
if (x > 1 && x < gdvLocal.Columns.Count - 1)
gdvLocal.Columns[x].Visible = visible;
}
}
}
--
MCP Year 2005, Philippines
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownlist in EditItemTemplate Gridview Problem den 2005 ASP .Net Web Controls 1 10-11-2006 11:44 AM
No Value: DropDownlist in EditItemTemplate Gridview Problem =?Utf-8?B?ZGVuIDIwMDU=?= ASP .Net 0 10-11-2006 11:34 AM
How to set selection in dropdownlist included in a Gridview <EditItemTemplate> WT ASP .Net 2 05-03-2006 02:59 PM
gridview: selected value of dropdownlist in edititemtemplate =?Utf-8?B?Tkg=?= ASP .Net 2 03-27-2006 12:43 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM



Advertisments