all groups > asp.net building controls > april 2007 >
You're in the

asp.net building controls

group:

User Control in Repeater


User Control in Repeater NKaufman
4/13/2007 5:30:37 AM
asp.net building controls: Hello,

I have the following requirement:


I have to create a Repeater control which has two columns. One has
text and other's got to have
(1) a group of radiobuttons OR
(2) a group of checkboxes OR
(3) a textbox


The caption of the radiobutton/checkbox is to come from database as a
comma delimited string. I'd like to use a user control that will take
- type of control to display and caption string and output html


How should I proceed? and how can I iterate through the rows to get
the answer and save it to the database?


Please let me know if the above is not clear and I will try to
provide
more info.


Thanks
Re: User Control in Repeater Teemu Keiski
4/15/2007 12:00:00 AM
Hi,

you can iterate the repeater with this idea:

foreach (RepeaterItem rptItem in Repeater1.Items)
{
YourUserControlType uc =
(YourUserControlType )rptItem.FindControl("YourUserControlId");
//Do something with the uc, access properties etc tec
}

You might also want see my related blog post about databound controls

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/archive/2007/02/25/Understanding-the-naming-container-hierarchy-of-ASP.NET-databound-controls.aspx


And if your user control exposes everything via its properties, you could
access them at this point when iterating the Repeater.


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


[quoted text, click to view]
AddThis Social Bookmark Button