(DATAGRID)How to put 1st column in one row and the rest in the row below?

For example, I want to display a FIELD1,FIELD2,FIELD3,FIELD4 from a table in a datagrid this way:


----------------------------------------------
FIELD1("colspanning it")
----------------------------------------------
FIELD2 | FIELD3 | FIELD4

----------------------------------------------
FIELD1("colspanning it")
----------------------------------------------
FIELD2 | FIELD3 | FIELD4

----------------------------------------------
FIELD1("colspanning it")
----------------------------------------------
FIELD2 | FIELD3 | FIELD4

and so on. is this possible with a datagrid?
Thanks
0
fetcher
11/11/2003 3:27:50 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
549 Views

Similar Articles

[PageSpeed] 5

This is a lot easier with a DataList, where you can define the template for a whole row. The problem with the datagrid is that it's basic assumption is that you will be displaying one row (and only one) in the grid for each row of data in the datasource. 

It is possible to "fool" the grid by programatically adding items to the underlying table after the grid has created an initial item, but the method is pretty kludgey. It is useful for adding intermediate "header" or "totals" rows, but not for every row.
But with the datalist, you can specify two rows of detail for each row in the datalist easily.
Jim


MS MVP ASP.NET [VC++/MFC emeritus]


Old Dog Learns New Tricks

Preferred programming language: cuneiform on clay tablets
0
JimRoss
11/11/2003 3:34:29 PM
Ok. I will try that. The datagrid that I have has textboxes(with validation controls) in templates columns so that the user can edit all rows at the same time. Then I have a SaveButton that iterates through the datagrid and gets the values....

I have something like this:

// Loop through the items in the datagrid.
foreach (DataGridItem di in dbEscalas.Items)
{
// Make sure this is an item and not the header or footer.
if (di.ItemType == ListItemType.Item || di.ItemType == ListItemType.AlternatingItem)
{
......
.....

so since I haven't used a datalist yet I wonder if it uses the same mechanism?
Thanks again
0
fetcher
11/11/2003 3:50:25 PM
Reply: