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 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilesh ShahPosted Apr 26, 2017, 11:06 AM