Results 1 to 2 of 2

Thread: Display image in Datagrid

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Display image in Datagrid

    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.
    VB Code:
    1. Dim dtUsers As JHALibrary.ADORoutines.CDataTableAdvanced
    2. Dim drUsers As DataRow
    3. dtUsers = objConn.GetUsersForProduct(ProductID)
    4.  
    5. For Each drUsers in dgUsers.Rows
    6.    If(dgUsers("FieldName") <> 0) Then
    7.       'Display the true image
    8.    Else
    9.       'Display the false image
    10.    End If
    11. Next
    12.  
    13. dgUsers.DataSource = dtUsers
    14. dgUsers.DataKeyField = "EnhancementSubmitterID"
    15. dgUsers.DataBind()
    I am lost as to what code I should place there, since nothing seems to work.
    Last edited by Memnoch1207; Jan 28th, 2004 at 10:57 AM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Nevermind, I figured a way to do it...
    Code:
    <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)
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width