Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DataGrid header.

0 views
Skip to first unread message

David

unread,
Jan 23, 2003, 2:07:34 PM1/23/03
to
Hello everyone.

Is it possible to have a text and an image in the header
of the DataGrid web control? I need to show the column
name and the order the table is sorted by (down or up
arrow). I was able to make the DataGrid be switched from
ascending to descending and back by clicking on the column
header but I can put only text or image there.

Any help is greatly appreciated.

Steve C. Orr, MCSD

unread,
Jan 23, 2003, 2:28:49 PM1/23/03
to
I should have also mentioned that you'll need to check to make sure the item created is the header row, since that's the only row you want to change.
You do that with code like this:

If

e.Item.ItemType = ListItemType.Header Then

I should also mention that as an alternative you could also likely solve your problem by using datagrid templates.  Here's more info on that technique:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskAddingTemplateColumnToDataGridWebControl.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

 
"Steve C. Orr, MCSD" <st...@orr.net> wrote in message news:#STYNTxwCHA.1096@TK2MSFTNGP10...
You can modify the HTML for the header cells in the ItemCreated event of the datagrid.
That way you can put whatever you want in there.
You should be able to use a line of code similar to this in there:
e.Item.Cells(4).Text = "some text for column 4<img src='myimage.gif'>"
 
Here's more info:

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
 
 
 

Steve C. Orr, MCSD

unread,
Jan 23, 2003, 2:22:58 PM1/23/03
to
You can modify the HTML for the header cells in the ItemCreated event of the datagrid.
That way you can put whatever you want in there.
You should be able to use a line of code similar to this in there:
e.Item.Cells(4).Text = "some text for column 4<img src='myimage.gif'>"
 
Here's more info:

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
 
 
 
0 new messages