iFinity Blogs 

By Bruce Chapman on Tuesday, April 13, 2010 9:26 AM
I’ve come across this problem a few times, and have usually just worked my way around it.

The problem is when you want to create a list of Radio Buttons to display on a page, and you need to show these with other data, using an ASP.NET repeater (or DataList, or DataGrid).

Here’s what your code might look like:





















If you run a DataBind to show values for this repeater, the Html will end up something like this:

    One     name="rptValues$ctl01$options" />     name="rptValues$ctl01$txtValue" />

    Two     name="rptValues$ctl02$options" />     name="rptValues$ctl02$txtValue" />

(Note I haven’t shown the ‘code behind’ here, just take it that I have bound to a string list which consists of ‘one’ and ‘two’)

Because the two ‘radio’ inputs have a different ‘name’ attribute, then they will act independently of each other, and you’ll be...
Bruce Chapman
Hi, I'm Bruce Chapman, and this is my blog. You'll find lots of information here - my thoughts about business and the internet, technical information, things I'm working on and the odd strange post or two.

 

Share this
Get more!
Subscribe to the Mailing List
Email Address:
First Name:
Last Name:
You will be sent a confirmation upon subscription

 

Follow me on Twitter
Stack Exchange
profile for Bruce Chapman at Stack Overflow, Q&A for professional and enthusiast programmers
Klout Profile