PC Review

Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

No Value: DropDownlist in EditItemTemplate Gridview Problem

Posts: n/a
      11th Oct 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

<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" />

<asp:Label ID="lblFileType" runat="server"
Text='<%# Eval("FileType") %>'></asp:Label>
<asp:DropDownList ID="ddlType"
runat="server" DataSource='<%# LoadFileTypes() %>'
DataTextField="FileTypeCode" DataValueField="FileTypeCode"

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

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)
if (...)
else if (choice == "Files")
return (DataTable) Session["dtFiles"];
return null;
return null;

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

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" &&
gdvLocal.Columns[x].Visible = visible;
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

Thread Tools
Rate This Thread
Rate This Thread:

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
problem using DropDownList in EditItemTemplate Jeff Microsoft ASP .NET 0 13th Nov 2008 02:35 PM
DataGrid EditItemTemplate-- how to retrieve a DropDownList validator? Steve Hershoff Microsoft ASP .NET 2 11th Apr 2007 09:12 PM
How to set selection in dropdownlist included in a Gridview <EditItemTemplate> WT Microsoft ASP .NET 2 3rd May 2006 03:59 PM
gridview: selected value of dropdownlist in edititemtemplate =?Utf-8?B?Tkg=?= Microsoft ASP .NET 2 27th Mar 2006 01:43 PM
DropDownList in EditItemTemplate George Durzi Microsoft ASP .NET 1 27th Sep 2004 06:36 PM




All times are GMT +1. The time now is 02:21 PM.