Home > Software engineering >  Row editing in grid view C#
Row editing in grid view C#

Time:09-16

I am working on a nested gridview. However I'm unable to set the child gridview in edit mode. I'm able to set the main gridview in edit mode but the child gridview doesn't get into edit mode. Here's my code..

protected void ChildGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView g2 = (GridView)sender;

    g2.EditIndex = e.NewEditIndex;

    BOGridView.DataBind(); // binding this gridview to main gridview.
}

enter image description here

Any help is appreciated. Thanks in advance.

CodePudding user response:

You do not need to DataBind the parent GridView. All you need to do is update the current child gridview.

protected void ChildGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
    var g2 = (GridView)sender;

    g2.EditIndex = e.NewEditIndex;

    g2.DataSource = YourDataSource;
    g2.DataBind();
}
  • Related