Reputation: 28771
I am using a Gridview
inside another GridView
.
I want to implement edit / update in child Gridview
.
<asp:TemplateField>
<ItemTemplate>
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false"
onrowediting="gvChildGrid_RowEditing" >
</ItemTemplate>
</asp:Template>
onrowedit for child gridview is like below
protected void gvChildGrid_RowEditing(object sender, GridViewEditEventArgs e)
{
gvChildGrid.EditIndex = e.NewEditIndex;
BindData();
}
This is showing error
gvChildGrid doesnot exist in current context .
Please help how to implement edit /Update child gridview
Upvotes: 0
Views: 397
Reputation: 13381
try change your code like this
protected void gvChildGrid_RowEditing(object sender, GridViewEditEventArgs e)
{
((GridView)sender).EditIndex = e.NewEditIndex;
BindData();
}
UPDATE
in runtime you cann't get nested gridview by name, because it inside template field, so you can get it from sender
object
Upvotes: 1