Re: How to display images in datagrid column header?
From: Craig Deelsnyder (cdeelsny_at_no_spam_4_meyahoo.com)
Date: 06/14/04
- Next message: Buz Waitz: "target size"
- Previous message: John Morgan: "Problem with inheritance of code behind page"
- In reply to: Alek Davis: "Re: How to display images in datagrid column header?"
- Next in thread: Alek Davis: "Re: How to display images in datagrid column header?"
- Reply: Alek Davis: "Re: How to display images in datagrid column header?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Jun 2004 17:57:42 -0500
On Mon, 14 Jun 2004 15:23:10 -0700, Alek Davis
<alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote:
> Forgot to mention: I generate the image tag (with a hyperlink)
> dynamically
> using a function in code behind. So I was looking to an option like this:
>
> <ASP:TEMPLATECOLUMN
> HeaderText='Info <%= GetHelpIconHtml("HelpTopicID") %>'>
>
> The goal would be to produce HTML like this:
>
> <TD...>Info <A Href=...><IMG Src=...></A></TD>
>
> where <A Href.../A> is generated by the GetHelpIconHtml function in
> code-behind.
>
> Alek
>
As you see, the DataColumn has a HeaderText property:
it may be easier to do this in the code-behind than in the aspx binding
statement, even tho what you have looks OK as well. But you should be
able to use HTML like <img src=""...> in the HeaderText and it'll render
to an image when displayed. If you want to do it in the code-behind,
there is an ItemCreated event on the datagrid you can use in code-behind
and check e.Item.ItemType and if it's a header item type, you could set
the images then by adding controls to the e.Item.Cells. Or after binding,
you could go back and loop thru the cols and do it then (setting
col.HeaderText).
Here's a slightly different example, where the guy is setting his own
images in the header when sorting:
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET
- Next message: Buz Waitz: "target size"
- Previous message: John Morgan: "Problem with inheritance of code behind page"
- In reply to: Alek Davis: "Re: How to display images in datagrid column header?"
- Next in thread: Alek Davis: "Re: How to display images in datagrid column header?"
- Reply: Alek Davis: "Re: How to display images in datagrid column header?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|