-
DataGrid
Here's a problem I faced not long ago:
Let's say I've got a DataGrid. Column 1 contains integers in the range of 1-10. Let's say I want to add a Column 2 that presents one of three images: A smiley face when Column 1 >= 7, a sad face when Column 1 is <= 3 and a neutral face for 4-6. Is that feasible?
Thanks
cudabean
-
You need to use a helper method.
Check out this url :
http://www.datagridgirl.com/faq.aspx
-
Thanks! You know, the styling on that site is both hilarious and outrageous.
So, I should be able to do something like this? (I took their example and inserted the img references in the codebehind)
aspx:
Code:
<asp:DataGrid id="YourID" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Status">
<ItemTemplate>
<%#ShowStatus(Container.DataItem("online"))%>
</ItemTemplate>
</asp:TemplateColumn>
codebehind
Code:
Function ShowStatus(val)
If val = 0 Then
ShowStatus = "<img src=Offline.gif>"
Else
ShowStatus = "<img src=Online.gif>"
End If
End Function
-
Yep that girl really does like her datagrids.