Nested Gridview and Newly Created Row Dissappears on postback
<p>I have a 2 Gridvies the first load data of pages and on the edit button a newly added row appears underneath. It then creates a grid in that row the problem is when there is a post back i need to have that row recreated. In my code the newly added GridView editing event handler doesn't fire I need to be able to recreate that row on postback and have the GridView that fire the post back go into edit mode. I don't know what todo at this point can someone help me please, here is my code. by the way PageSettings is a GridView and WebservicesGrid is the nested one</p>

<pre><code>protected void PageSettings_RowEditing(object sender, GridViewEditEventArgs e)
{
    ((GridView)sender).EditIndex = e.NewEditIndex;
    EditIndex = e.NewEditIndex;
    lblStatus.Text = string.Format("Editing Row: {0}", (e.NewEditIndex + 1).ToString());
}

public int EditIndex = -1;
protected void PageSettings_DataBound
     (object sender, GridViewRowEventArgs e)
{

    if ((e.Row.RowState &amp; DataControlRowState.Edit) &gt; 0 &amp;&amp; 
        ((GridView)sender).EditIndex == EditIndex 
        || 
        Request["__EVENTTARGET"] == "ctl00$MainContent$PageSettings$ct103$WebServicesGridView" )
    {            
        GridViewRow row = new GridViewRow(e.Row.RowIndex+ 2, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
        row.CssClass = "gridview-alternating-row";
        //row.Cells.AddRange(CreateCells());

        TableCell cell;
        cell = new TableCell();
        cell.ColumnSpan = 2;
        row.Cells.Add(cell);
        cell = new TableCell();
        cell.ColumnSpan = 4;

        SystemPage SysPage = e.Row.DataItem as SystemPage;
        GridView gv = CreateGridView("WebServices", SysPage);
        cell.Controls.Add(gv);
        row.Cells.Add(cell);
        // Row Edting Event not firing either
        gv.RowEditing += new GridViewEditEventHandler(services_RowEditing);

        Table table = e.Row.Parent as Table;
        table.Rows.AddAt(e.Row.RowIndex + 2, row);
    }
}

private GridView CreateGridView(string type, SystemPage page)
{
    GridView services = new GridView();
    switch (type)
    {
        case "WebServices" :

            CommandField CommandEdit = new CommandField();
            CommandEdit.ButtonType = ButtonType.Link;
            CommandEdit.ShowEditButton = true;
            CommandEdit.UpdateText = "Update";
            CommandEdit.EditText = "Edit";                
            services.Columns.Add(CommandEdit);

            BoundField WebServiceName = new BoundField();
            WebServiceName.DataField = "name";
            WebServiceName.HeaderText = "WebService";
            services.Columns.Add(WebServiceName);

            BoundField WebServiceUrl = new BoundField();
            WebServiceUrl.DataField = "url";
            WebServiceUrl.HeaderText = "Url";
            services.Columns.Add(WebServiceUrl);

            List&lt;WebService&gt; list = new List&lt;WebService&gt;();
            list.Add(new WebService { Name = "Test", Url = "Test" });

            services.ID = "WebServicesGridView";
            services.AutoGenerateColumns = false;

            services.DataSource = list;
            services.DataBind();

            break;
    }

    return services;

}

protected void services_RowEditing(object sender, GridViewEditEventArgs e)
{
    ((GridView)sender).EditIndex = e.NewEditIndex;
    lblSubGridStatus.Text = e.NewEditIndex.ToString();

    PageSettings.DataBind();
}
</code></pre>
