datagrid in datagrid

B

BK Kim

Hello.

I am trying to use dataGrid in a dataGrid, meaning first DataGrid displays
some information and on each row, it is going to have another datagrid to
display detailed information.

I was able to do it in two dataGrid. ( one datagrid containing a datagrid in
each row )

But I was not able to do it in three dataGrid.

Generally, I bind the first DataGrid and on ItemCreated event, I add a cell
into that row containing dataGrid. ( works fine )

private void grdTemp_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )

{

System.Web.UI.WebControls.DataGrid grdTemp2 = new DataGrid();

grdTemp2.ItemCreated += new
System.Web.UI.WebControls.DataGridItemEventHandler(this.grdTemp2_ItemCreated
);

e.Item.Cells[0].Controls.Add(grdTemp2);


grdTemp2.DataSource = getData(2);

grdTemp2.DataBind();

}


}

private void grdTemp2_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )

{

System.Web.UI.WebControls.DataGrid grdTemp3 = new DataGrid();


grdTemp3.DataSource = getData(3);

grdTemp3.DataBind();

e.Item.Cells[0].Controls.Add(grdTemp3);


}

}


Does anyone knows, how to do this or why this code doesn't work?
Thanx in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top