PDA

Click to See Complete Forum and Search --> : Display image in Datagrid


Memnoch1207
Jan 28th, 2004, 08:42 AM
I am trying to display an image in a datagrid. I have a field in the database that is true or false. What I want to do is if the field is true, then display the true image in the datagrid, otherwise display the false image.

Dim dtUsers As JHALibrary.ADORoutines.CDataTableAdvanced
Dim drUsers As DataRow
dtUsers = objConn.GetUsersForProduct(ProductID)

For Each drUsers in dgUsers.Rows
If(dgUsers("FieldName") <> 0) Then
'Display the true image
Else
'Display the false image
End If
Next

dgUsers.DataSource = dtUsers
dgUsers.DataKeyField = "EnhancementSubmitterID"
dgUsers.DataBind()

I am lost as to what code I should place there, since nothing seems to work.

Memnoch1207
Jan 28th, 2004, 11:42 AM
Nevermind, I figured a way to do it...

<asp:TemplateColumn HeaderText="Submitter">
<HeaderStyle CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<img src='images\<%# Databinder.Eval(Container.DataItem,"QualifiedSubmitter")%>.gif'>
</ItemTemplate>
</asp:TemplateColumn>

and the images are named (0.gif and -1.gif)