Results 1 to 3 of 3

Thread: Image in datagrid

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Image in datagrid

    I have a field in a dataset called CALLACK which contains either 1 or 0.

    In my datagrid I wish to display an image based upon this value. To do this I use itemtemplate :

    <asp:TemplateColumn HeaderText="" HeaderStyle-Width="25" Visible="True">
    <ItemTemplate>
    <asp:image runat="server" ImageUrl='<%# SetDisImage(Databind.Eval Container,"DataItem.dbo.view_customers_calls.CALLACK"))%>'>
    </asp:image>
    </itemtemplate>
    </asp:TemplateColumn>

    The SetDisImage function is as follows:

    Protected Function SetDisImage(ByVal bol As Boolean)
    Dim strURL = ""
    Dim strYes = "status_new.gif"
    Dim strNo = "status_open.gif"

    If bol Then
    strURL += strYes
    Else
    strURL += strNo
    End If
    Return strYes
    End Function

    WHen I run the page I get the following error:

    Expression does not produce a value.

    Can someone please tell me what I am doing wrong. The code I got from the web and it seems pretty clear to me.

    Thanks in Advance

    Parksie

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: Image in datagrid

    VB Code:
    1. Protected Function SetDisImage(ByVal bol As Boolean)
    2.         Dim strURL = ""
    3.         Dim strYes = "status_new.gif"
    4.         Dim strNo = "status_open.gif"
    5.  
    6.         If bol Then
    7.              strURL += strYes
    8.         Else
    9.              strURL += strNo
    10.         End If
    11.         Return [b]strURL[/b] ' Could it be this?
    12. End Function

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    I changed it just for testing purposes.

    If I use :

    <asp:image runat="server" ImageUrl='<%# SetDisImage(1)%>'>

    it works fine. There must be something wrong with the parameter but I dont know what.

    Parksie

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