Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Can't get subroutine/helper function to work in Datalist control

Reply
Thread Tools

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

 
 
Chumley the Walrus
Guest
Posts: n/a
 
      06-14-2004
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
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      06-14-2004
You want to use a Function rather than a Sub and make sure it returns a
string.

Actually, you might be able to shorten the process by using IIF right in
your .aspx file:

<asp:Image id="Image1" runat="server" ImageUrl='<%#
iif(DataBinder.Eval(Container.DataItem,
"StringValue")="","&nbsp;",DataBinder.Eval(Contain er.DataItem,"StringValue"))
%>'>

Ken


"Chumley the Walrus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataList inside user control - ItemCommands don't work if I dont populate List on every page load yousuf ASP .Net 0 01-29-2006 11:49 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Can't get subroutine/helper function to work in Datalist control Chumley the Walrus ASP .Net 2 06-15-2004 11:30 AM
DataList in DataList acko bogicevic ASP .Net 2 11-11-2003 08:31 AM
Datalist in Datalist How? Gönen EREN ASP .Net 0 08-22-2003 02:41 PM



Advertisments