Unable to Add attributes to ListItem In a Radio Buttton List

J

Jay Hombal

Hi
I have have user control. This user control has two asp.net controls a
Radio button list and text box control. The radio button list is databound
and the values come from code tables with key value pairs. I have many tables
for which I need to render radio button list.
The code tables in many cases have a value 'Other'. If the value if Other
and the user selects this radio button from the list I need to show the radio
button. I have achieved this currently by setting autopostback= true for
radio button list and handling the check logic in selection changed event for
the same control.
But the problem is many controls are used in each page and auto post back
is resulting in poor performace. So I am trying to aviod doing check on
server side and try to handle it on client side. But the script does not work
as
each radio button generates a name="controlname:controlId1" as the name. The
cluprit i think is the ':' my script does not work with ':'. So i am trying
to override the name attribute for the Radio button generated in the list to
use a common name by adding attributes on server side while the control is
being generated.
But for some reason I am not able to add any attrubutes to the attributes
collection of List Item control

Here is sample code in page_load event of the user control
<code>
Dim listItem As ListItem = New ListItem("Yes", "Yes")
Dim listItem1 As ListItem = New ListItem("No", "No")
Dim listItem2 As ListItem = New ListItem("Other", "other")
listItem.Attributes.Add("name", "group")
listItem1.Attributes.Add("name", "group")
listItem2.Attributes.Add("name", "group")
RadioButtonList1.Items.Add(listItem)
RadioButtonList1.Items.Add(listItem1)
RadioButtonList1.Items.Add(listItem2)

Note: the attribute name never shows up, rather any other attribute also
does not show up.
</code>

I would appriciate if some one guides me here....

Thanks
Jay

--
Jay Hombal
MCP,MCAD,MCSD
Senior XML Consultant
Software AG USA
Reston VA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top