Subroutine /helper function error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chumley the Walrus

    #1

    Subroutine /helper function error

    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(ByV al 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(Dat aBinder.Eval(Co ntainer.DataIte m,
    "Imagesubprod1" ))%>

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

    ...i get an "Expected end of statement " error on this line
  • Craig Deelsnyder

    #2
    Re: Subroutine /helper function error

    On 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <springb2k@yaho o.com>
    wrote:
    [color=blue]
    > 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(ByV al 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(Dat aBinder.Eval(Co ntainer.DataIte m,
    > "Imagesubprod1" ))%>[/color]

    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

    Comment

    • bruce barker

      #3
      Re: Subroutine /helper function error

      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" <springb2k@yaho o.com> wrote in message
      news:1ef65641.0 406101055.88521 02@posting.goog le.com...[color=blue]
      > 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(ByV al 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(Dat aBinder.Eval(Co ntainer.DataIte m,
      > "Imagesubprod1" ))%>
      >
      > When I form the header for the sub as follows:
      > Public Sub checkforimg(ByV al Imagesubprod1 As String) As string
      >
      > ..i get an "Expected end of statement " error on this line[/color]


      Comment

      Working...