Subroutine /helper function error

Discussion in 'ASP .Net' started by Chumley the Walrus, Jun 10, 2004.

  1. I'm using a subroutine/helper function display an image (the image
    would be displayed inside a datalist control's <itemtemplate> )

    <script language="VB" runat="server">
    Public Sub checkforimg(ByVal Imagesubprod1 As String)
    If Imagesubprod1 <> "" then
    response.write(Imagesubprod1)
    Else
    response.write("nbsp;")
    End If
    End Sub
    </script>

    .... but I get an "Overload resolution failed because no accessible
    'ToString' can be called with these arguments:" error when it comes
    time to check for the image as follows.

    <%# checkforimg(DataBinder.Eval(Container.DataItem,
    "Imagesubprod1"))%>

    When I form the header for the sub as follows:
    Public Sub checkforimg(ByVal Imagesubprod1 As String) As string

    ...i get an "Expected end of statement " error on this line
     
    Chumley the Walrus, Jun 10, 2004
    #1
    1. Advertising

  2. On 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <>
    wrote:

    > I'm using a subroutine/helper function display an image (the image
    > would be displayed inside a datalist control's <itemtemplate> )
    >
    > <script language="VB" runat="server">
    > Public Sub checkforimg(ByVal Imagesubprod1 As String)
    > If Imagesubprod1 <> "" then
    > response.write(Imagesubprod1)
    > Else
    > response.write("nbsp;")
    > End If
    > End Sub
    > </script>
    >
    > ... but I get an "Overload resolution failed because no accessible
    > 'ToString' can be called with these arguments:" error when it comes
    > time to check for the image as follows.
    >
    > <%# checkforimg(DataBinder.Eval(Container.DataItem,
    > "Imagesubprod1"))%>


    looks like it's having trouble converting the value you're passing in thru
    databinding to a String. If you have Option Strict on, you might try
    either casting the value in the databinding statement to a string before
    passing it in, or change the parameter in your method above to an Object
    and then cast it inside the function itself.

    Otherwise verify the value in your datasource is truly capable of being a
    string.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
     
    Craig Deelsnyder, Jun 10, 2004
    #2
    1. Advertising

  3. Chumley the Walrus

    bruce barker Guest

    IE does not support inline images, so you code should be writing something
    like: <img src=url> not the binary image.

    -- bruce (sqlwork.com)


    "Chumley the Walrus" <> wrote in message
    news:...
    > I'm using a subroutine/helper function display an image (the image
    > would be displayed inside a datalist control's <itemtemplate> )
    >
    > <script language="VB" runat="server">
    > Public Sub checkforimg(ByVal Imagesubprod1 As String)
    > If Imagesubprod1 <> "" then
    > response.write(Imagesubprod1)
    > Else
    > response.write("nbsp;")
    > End If
    > End Sub
    > </script>
    >
    > ... but I get an "Overload resolution failed because no accessible
    > 'ToString' can be called with these arguments:" error when it comes
    > time to check for the image as follows.
    >
    > <%# checkforimg(DataBinder.Eval(Container.DataItem,
    > "Imagesubprod1"))%>
    >
    > When I form the header for the sub as follows:
    > Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
    >
    > ..i get an "Expected end of statement " error on this line
     
    bruce barker, Jun 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chumley the Walrus
    Replies:
    2
    Views:
    472
    John Saunders
    Jun 15, 2004
  2. Replies:
    1
    Views:
    370
    Karl Seguin [MVP]
    Jan 12, 2006
  3. Chumley the Walrus

    Can't get subroutine/helper function to work in Datalist control

    Chumley the Walrus, Jun 14, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    102
    Ken Cox [Microsoft MVP]
    Jun 14, 2004
  4. kevin
    Replies:
    1
    Views:
    373
    Kairi Zikpin
    Jul 21, 2006
  5. king
    Replies:
    5
    Views:
    188
Loading...

Share This Page