dataGrid in DataGrid

dataGrid in DataGrid

Post by BK Ki » Wed, 25 Feb 2004 05:10:53


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
 
 
 

dataGrid in DataGrid

Post by Alvin Brun » Wed, 25 Feb 2004 09:59:52

You are trying to build drill thru functionality from what i can see. You
are taking an unnecessary complex route. One approach which works well is to
have a details button along with each row displayed in the grid. Clicking
details on this button means you want details for that particular row, so
you grab the relevant row data, build a query with a whereclause based on
the selected row and go grab that specific data to display in the datagrid.
The new datagrid also contains a details button. In that way, you can drill
infinitely without having to keep track of anything, all you need is the
selected row to build your where clause part of the query. Make sense?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://www.yqcomputer.com/


in
cell
System.Web.UI.WebControls.DataGridItemEventHandler(this.grdTemp2_ItemCreated

 
 
 

dataGrid in DataGrid

Post by BK Ki » Wed, 25 Feb 2004 13:20:59

f I have that option, I wouldn't worry about this but I cannot approach in
that way.

In our requirement spec, we have our demo to follow( which is not what you
just discribed )

Is there any other way to achieve this?

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:uKTSKGn% XXXX@XXXXX.COM ...
to
datagrid.
drill
displays
to
datagrid
System.Web.UI.WebControls.DataGridItemEventHandler(this.grdTemp2_ItemCreated


 
 
 

dataGrid in DataGrid

Post by Marshal An » Wed, 25 Feb 2004 14:02:10

Hi Kim,
Sounds like you have a master detail scenario.
You can use a DataList and DataGrid together to acheive the same.
Here is a very good article on this by Bipin Joshi.
http://www.yqcomputer.com/

Hope this helps.
Regards,
Marshal Antony
.NET Developer
http://www.yqcomputer.com/





in
cell
System.Web.UI.WebControls.DataGridItemEventHandler(this.grdTemp2_ItemCreated