Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > User controls in DataList

Reply
Thread Tools

User controls in DataList

 
 
Amil Hanish
Guest
Posts: n/a
 
      08-14-2006
I want to create a bunch of like user controls and display them in a
DataList.

Does anyone have a GOOD example of how to do this?

I thought I had it...I added the user control to my <ItemTemplate>, created
an array of user controls in my code behind and set the DataSource and
called DataBind. But, all the user controls are unitialized when the page
is rendered.

Amil


 
Reply With Quote
 
 
 
 
Riki
Guest
Posts: n/a
 
      08-14-2006
Amil Hanish wrote:
> I want to create a bunch of like user controls and display them in a
> DataList.
>
> Does anyone have a GOOD example of how to do this?
>
> I thought I had it...I added the user control to my <ItemTemplate>,
> created an array of user controls in my code behind and set the
> DataSource and called DataBind. But, all the user controls are
> unitialized when the page is rendered.
>
> Amil


Just put the user control in the template like you would do with any other
control (e.g. a textbox).
Bind the properties of the user control that you need.

The DataList will create the "array" of user controls automatically.

The setup of the user control should be done by the user control itself as
soon as its properties are assigned.
Whether it is in a template, or just in a page by itself, should not make a
difference.

--
Riki


 
Reply With Quote
 
 
 
 
Amil Hanish
Guest
Posts: n/a
 
      08-14-2006
Ahh...I think I've got it. I was creating my own array, but so was
asp.net...that's the reason all my objects were not initialized...they were
asp.net's objects (not the ones I created).

It's sort of a complex algorithm to set the user control properties. Can I
call a protected method from the datalist <ItemTemplate>, passing it the
asp.net object, and then let my method set the specific values?

Thanks.

Amil


"Riki" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Amil Hanish wrote:
>> I want to create a bunch of like user controls and display them in a
>> DataList.
>>
>> Does anyone have a GOOD example of how to do this?
>>
>> I thought I had it...I added the user control to my <ItemTemplate>,
>> created an array of user controls in my code behind and set the
>> DataSource and called DataBind. But, all the user controls are
>> unitialized when the page is rendered.
>>
>> Amil

>
> Just put the user control in the template like you would do with any other
> control (e.g. a textbox).
> Bind the properties of the user control that you need.
>
> The DataList will create the "array" of user controls automatically.
>
> The setup of the user control should be done by the user control itself as
> soon as its properties are assigned.
> Whether it is in a template, or just in a page by itself, should not make
> a difference.
>
> --
> Riki
>



 
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
using javascript in User controls to access server controls of the user control Faizan Ahmed ASP .Net Building Controls 1 01-04-2005 04:09 PM
using javascript in User controls to access server controls of the user control Faizan Ahmed ASP .Net Web Controls 1 01-04-2005 04:09 PM
handling radio button event in user controls datalist manu_srinivasa ASP .Net 0 11-24-2004 09:57 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments