Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Subheader (subcolumns)

Thread Tools

Subheader (subcolumns)

Tumurbaatar S.
Posts: n/a
Can anybody help me to make my DataGrid header
like below one?
| | | SomeText
H1| H2 | H3 | -------------------
| | | H4 | H5 | H6

In the plain HTML, this can be achieved using RowSpan and ColumnSpan
attributes. But how to apply it to the DataGrid?
I have some experience in manipulating a DataGrid content from a code.
So I decided to add one extra header row below the existing one and thru
modifying theirs cells, get what I need. But my test code failed at a very
first step!
I called below code from DataGrid_Prerender and instead of getting an extra
header row with a text "test", I got an empty row. Without <td> elements

//this fragment from browser's Source View

//the code from Grid_Prerender()

DataGridItem hdr = null, sub;
TableCell cell;
int c;

for (c = 0; c < Grid.Controls[0].Controls.Count; c++)
hdr = Grid.Controls[0].Controls[c] as DataGridItem;
if (hdr != null && hdr.ItemType == ListItemType.Header)
if (hdr == null || hdr.ItemType != ListItemType.Header)
sub = new DataGridItem(-1, -1, ListItemType.Header);
cell = new TableCell();
cell.ColumnSpan = hdr.Cells.Count;
cell.Text = "test";
Grid.Controls[0].Controls.AddAt(c + 1, sub);

If above problem will be solved, my next step is to try to
cells from above 2 header rows and, may be, I will get some result.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding subHeader to dataGrid rosh shah ASP .Net Datagrid Control 1 10-05-2004 12:40 PM