Two exceptions:
- Index out of bound
- FindControl returns null (it's pretending or not detecting the controls)
cs code: (for now dropdownlist just needs to be populated at editing mode)
protected void GridView3_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView3.EditIndex = e.NewEditIndex;
ShowData("a"); //bind data
GridViewRow gVR = GridView3.Rows[GridView3.EditIndex];
aspx code:
<asp:TemplateField HeaderText="x" ItemStyle-CssClass="ix">
<EditItemTemplate>
<asp:DropDownList ID="xnList" runat="server" Text='<%# Bind("[columnx]")%>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("[columnx]") %>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="ix" />
</asp:TemplateField>
Given above snippet, right at the 3rd line I am getting following error. This is absurd as the same works well for other gridview and this gridview has 10 rows, so definitely not out of bound. What could be the issue here?
References:
EDIT:
Those who are generously trying and sparing their time to help me out with a solution, please check out Jeff Atwood's blog post about Page.FindControl
. Reading it, I feel my dropdownlist is definitely a child within Gridview... Given this post, it comes much closer to what I have encountered..
But I am not 100% sure, if same case applies to what I am struggling with, since I have two gridviews. However only one has edit mode controls - the other is plain plain gridvos. Can someone show me the right direction?
EDIT: I have tried each one of above link's answers/solution. None working as of now.
See Question&Answers more detail:os