by using the add button im trying to add rows to child grid view like this
protected void Add(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((ImageButton)sender).Parent.Parent;
GridView gv = (GridView)row.FindControl("Gridview1");
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("EmployeeKey", typeof(int)));
dt.Columns.Add(new DataColumn("tbName", typeof(string)));
dt.Columns.Add(new DataColumn("tbAmount", typeof(string)));
dt.Columns.Add(new DataColumn("tbEffDate", typeof(string)));
dr = dt.NewRow();
dr["EmployeeKey"] = gr.Cells[1].Text;
dr["tbName"] = string.Empty;
dr["tbAmount"] = string.Empty;
dr["tbEffDate"] = string.Empty;
dt.Rows.Add(dr);
ViewState["CurrentTable"] = dt;
gv.DataSource = dt;
gv.DataBind();
}
but its not working out child grid is not updating with rows can any body help
here is the source code
ShowHeader="true" DataKeyNames="EmployeeKey" AllowPaging="true"
PageSize="5" ForeColor="#333333" GridLines="None"
onpageindexchanging="gvEmpDetails_PageIndexChanging"
Width="80%" OnRowDataBound="gvEmpDetails_RowDataBound" OnRowCommand="gvEmpDetails_RowCommand" >
<%# Container.DataItemIndex + 1 %>
| Name | Amount | Effective Date |
ForeColor="#333333" GridLines="None" AutoGenerateColumns="false">
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Nilesh ShahRank #42 · 34.2K reputationPosted Apr 26, 2017, 7:06 AM EDT