I have two Grid View gridview1 and gridview2 inside an asp.net page. In order to bind data to gridview2 the gridview1 has to bind first because it depends on its values.
After finish binding gridview2 i want to add a new row in gridview1 and add the entire gridview2 inside the last row. So it is not possible to do it onRowDataBound of gridview1.
Is there a way to do that?.
I tried the following but is not working
grdQuestions.DataSource = LoadQuestions();
grdQuestions.DataBind();
grdAnswers.DataSource = LoadAnswer(Convert.ToInt32(grdQuestions.Rows[0].Cells[0].Text));
//GridView2.DataSource = LoadAnswer(2);
grdQuestions.Rows[0].Cells[0].Controls.Add(grdAnswers);
grdAnswers.DataBind();
grdQuestions.DataBind();
You can do it like below :
First create function that bind parent grid.
Then create function that bind child grid.
Then first call
BindParentGrid()and then callBindChildGrid().this link will also help you : http://www.codeproject.com/Articles/22928/GridView-within-GridView