Nested Grid View Probelm
-
Hi all, Iam doing nested data grid operations iam facing a problem in that please help me on this I have a gridview controls in asp.net page which is fetching data from data base then RowDataBound of that data grid iam creating gridview dynamically i.e means if there is 3 records in main gridview its creating 3 child gridview which has few data i want to access the data of the child grid views but i can access only the last child grid views data not all the child grid view data.i have attached my code here plase have a look on it. protected void GridView_RowDataBound1(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow) { id++; Int64 catId =Convert.ToInt64(e.Row.Cells[1].Text.ToString()); ds = new DataSet(); ds = objExitInterviewBLL.getQuestions(0, 'S', "", catId); int count = 0; if (ds.Tables[0].Rows.Count > 0) { NewDg = new GridView(); //NewDg= new GridView(); NewDg.ID = "NewDg" + id ; txtHidden.Text = txtHidden.Text + "," + NewDg.ID; NewDg.Attributes.Add("runat", "server"); NewDg.AutoGenerateColumns = false; BoundField bc1 = new BoundField(); bc1.DataField = "Sno"; bc1.HeaderText = "Sno"; BoundField bc2 = new BoundField(); bc2.DataField = "Question"; bc2.HeaderText = "Question"; BoundField bc3 = new BoundField(); bc3.DataField = "Responsetp"; bc3.Visible = false; TemplateField tc1 = new TemplateField(); tc1.ItemTemplate = new DataGridTemplate(ListItemType.Item, "Column1"); tc1.HeaderText = "Answers"; NewDg.Columns.Add(bc1); NewDg.Columns.Add(bc2); NewDg.Columns.Add(bc3); NewDg.Columns.Add(tc1); NewDg.DataSource = ds.Tables[0]; NewDg.DataBind(); while (ds.Tables[0].Rows.Count > count)