Display bitmap in datagrid column ???

G

Guest

Dear all

I have a datagrid which is bind to a dataset
On column in the dataset represent a STATUS
Instead of diplaying in my datagrid value of 1 and 0 corresponding to that
STATUS field, I would like to display a Green bitmap for a value of 1 and a
Red bitmap for a value of 0

how can I do that ??

thnaks for your help
regards
serge
 
G

Guest

If I understand your question, you could create a Template Column rather than
a Bound Column, as shown below:

<asp:TemplateColumn>
<ItemTemplate>
<asp:label id="Label1" runat="server" Text='<%# "<img src=" &
iif(DataBinder.Eval(Container, "DataItem.Status")=1,"green.bmp","red.bmp") &
">" %>'></asp:Label></ItemTemplate>
</asp:TemplateColumn>

Hope this helps.
 
G

Guest

hi chad

I have tried your suggestion and I get an error saying "Expression expected "

Any idea?
 
G

Guest

Sorry, you need to add the line continuations...

<asp:TemplateColumn>
<ItemTemplate>
<asp:label id="Label1" runat="server" Text='<%# "<img src=" & _
iif(DataBinder.Eval(Container, "DataItem.Status")=1,"green.bmp","red.bmp") & _
">" %>'></asp:Label></ItemTemplate>
</asp:TemplateColumn>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top