Results 1 to 4 of 4

Thread: DataGrid

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240

    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

  2. #2
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    You need to use a helper method.
    Check out this url :

    http://www.datagridgirl.com/faq.aspx

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    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

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Yep that girl really does like her datagrids.

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