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

0 comments:

Post a Comment