Showing posts with label datalist. Show all posts
Showing posts with label datalist. Show all posts

Saturday, March 31, 2012

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(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 lineOn 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <springb2k@.yahoo.com>
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
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@.yahoo.com> wrote in message
news:1ef65641.0406101055.8852102@.posting.google.com...
> 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

Thursday, March 22, 2012

supply itemtemplate for datalist at runtime

hi,
i'm programattically creating a datalist and rendering it to the page via a htmltextwriter.
i want to supply the itemtemplate at runtime but don't know how to do this.
i read the help at ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemWebUIITemplateClassTopic.htm
but i don't understand how that translates from what i'm familiar with in terms of a html template.. e.g:
<table><tr><td><% Container.DataItem %></td></tr></table
is there some way to just use a string? i'm probably being too simplistic.
thanks for any help
tim

\\ email: tim at mackey dot ie //
\\ blog: http://tim.mackey.ie //
67d0ebfec70e8db3Hi Tim:

One easy way to do this is to create the templates as user controls
and bind them dynamically.
http://msdn.microsoft.com/library/d...UserControl.asp

There is also a programmatic approach:
http://msdn.microsoft.com/library/d...namically. asp

HTH,

--
Scott
http://www.OdeToCode.com/

On Sun, 10 Oct 2004 12:18:31 +0100, "Tim Mackey" <tim@.scootasp.net>
wrote:

>hi,
>i'm programattically creating a datalist and rendering it to the page via a htmltextwriter.
>i want to supply the itemtemplate at runtime but don't know how to do this.
>i read the help at ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemWebUIITemplateClassTopic.htm
>but i don't understand how that translates from what i'm familiar with in terms of a html template.. e.g:
><table><tr><td><% Container.DataItem %></td></tr></table>
>is there some way to just use a string? i'm probably being too simplistic.
>thanks for any help
>tim
>
>\\ email: tim at mackey dot ie //
>\\ blog: http://tim.mackey.ie //
>67d0ebfec70e8db3
hi Scott,
many thanks for the reply.
this is very helpful.
tim

"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:kfhim0h6u1soa0t8pvfnjeld55djf9ltao@.4ax.com...
> Hi Tim:
> One easy way to do this is to create the templates as user controls
> and bind them dynamically.
> http://msdn.microsoft.com/library/d...UserControl.asp
> There is also a programmatic approach:
> http://msdn.microsoft.com/library/d...namically. asp
> HTH,
> --
> Scott
> http://www.OdeToCode.com/
> On Sun, 10 Oct 2004 12:18:31 +0100, "Tim Mackey" <tim@.scootasp.net>
> wrote:
>>hi,
>>i'm programattically creating a datalist and rendering it to the page via
>>a htmltextwriter.
>>i want to supply the itemtemplate at runtime but don't know how to do
>>this.
>>i read the help at
>>ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemWebUIITemplateClassTopic.htm
>>but i don't understand how that translates from what i'm familiar with in
>>terms of a html template.. e.g:
>><table><tr><td><% Container.DataItem %></td></tr></table>
>>
>>is there some way to just use a string? i'm probably being too
>>simplistic.
>>thanks for any help
>>tim
>>
>>
>>\\ email: tim at mackey dot ie //
>>\\ blog: http://tim.mackey.ie //
>>67d0ebfec70e8db3

supply itemtemplate for datalist at runtime

hi,
i'm programattically creating a datalist and rendering it to the page via a
htmltextwriter.
i want to supply the itemtemplate at runtime but don't know how to do this.
i read the help at ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemWe
bUIITemplateClassTopic.htm
but i don't understand how that translates from what i'm familiar with in te
rms of a html template.. e.g:
<table><tr><td><% Container.DataItem %></td></tr></table>
is there some way to just use a string? i'm probably being too simplistic.
thanks for any help
tim
\\ email: tim at mackey dot ie //
\\ blog: http://tim.mackey.ie //
67d0ebfec70e8db3Hi Tim:
One easy way to do this is to create the templates as user controls
and bind them dynamically.
http://msdn.microsoft.com/library/d...UserControl.asp
There is also a programmatic approach:
http://msdn.microsoft.com/library/d...a
lly.asp
HTH,
Scott
http://www.OdeToCode.com/
On Sun, 10 Oct 2004 12:18:31 +0100, "Tim Mackey" <tim@.scootasp.net>
wrote:

>hi,
>i'm programattically creating a datalist and rendering it to the page via a
htmltextwriter.
>i want to supply the itemtemplate at runtime but don't know how to do this.
>i read the help at ms-help://MS.NETFrameworkSDKv1.1/cpref/html/frlrfSystemW
ebUIITemplateClassTopic.htm
>but i don't understand how that translates from what i'm familiar with in t
erms of a html template.. e.g:
><table><tr><td><% Container.DataItem %></td></tr></table>
>is there some way to just use a string? i'm probably being too simplistic.
>thanks for any help
>tim
>
>\\ email: tim at mackey dot ie //
>\\ blog: http://tim.mackey.ie //
>67d0ebfec70e8db3
hi Scott,
many thanks for the reply.
this is very helpful.
tim
"Scott Allen" <bitmask@.[nospam].fred.net> wrote in message
news:kfhim0h6u1soa0t8pvfnjeld55djf9ltao@.
4ax.com...
> Hi Tim:
> One easy way to do this is to create the templates as user controls
> and bind them dynamically.
> http://msdn.microsoft.com/library/d...UserControl.asp
> There is also a programmatic approach:
> http://msdn.microsoft.com/library/d...br />
cally.asp
> HTH,
> --
> Scott
> http://www.OdeToCode.com/
> On Sun, 10 Oct 2004 12:18:31 +0100, "Tim Mackey" <tim@.scootasp.net>
> wrote:
>
>