473,383 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

User controls in DataList

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
Aug 14 '06 #1
2 2233
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
Aug 14 '06 #2
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" <ri**@dontnagme.comwrote in message
news:OE**************@TK2MSFTNGP06.phx.gbl...
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

Aug 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
1
by: Scott Schluer | last post by:
Hello, I've got myself a small problem and I'm hoping someone can help. I have a DataList called dlProducts (displays products from a database). Within the <ItemTemplate> container of the...
1
by: bill yeager | last post by:
I have a radiobuttonlist inside a datalist. I also have a datagrid inside the datalist. The data and the controls are rendering just fine. However, I need to find these controls inside the...
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
6
by: Davids | last post by:
having a 100% working aspx page I wanted to create a user control from a small DataList section (which has an ID="DataList1") of the page, so I created an ascx file with the DataList and Register...
2
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
1
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing...
1
by: Salim | last post by:
Hi, I'm trying to get UniqueID of a linkbutton. I have 2 web user controls. And a master page. In fisrst web user control there is a datalist. In datalist ItemCreated event, I try to find...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.