Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi experts..
i write the code for to add multiple radio buttons dynamically in table.. each cell have 4-5 radio buttons and each row have several radio buttons with different group name.. each radio button id i can add in arraylist. my problem how to get the checked radio buttons ids in arraylist..



please help me


Thank You in advance
Posted

If you finally want to get the id's of the selected radio-buttons in the ArrayList at server.I think you can do this with little javascript.

Say, you have a table with lots of radio buttons. And a submit button for submitting the form.

Follow these steps:

1)Make a javascript function which collects the ids of selected radio buttons and add them up in a string separated by unique character, and name it COLLECTOR FUNCTION. Say, the user selects cricket, tennis and basket ball radio buttons then the function should return "c#t#b" where # is the unique character and c,t,b are their respective ids.

2)When the user clicks on the submit button, in its event handler function call collector function
and make an ajax get request to the server with the output of collector function as query string.
eg. make request "arrylist.aspx?q=c#t#b"

3)Get that query string at server side, and split the ids through string's split function
and store them to array list.

Best of Luck.. :)
 
Share this answer
 
v2
Instead of ArrayList, use System.Collections.Generic.List<>: http://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx[^].

Non-generic non-specialized collections like ArrayList was rendered absolute as early as of .NET Framework v.2.0, when generics were introduced, so they should never be used in new development. The were not marked with [Obsolete] attribute just because there is nothing wrong with keeping them in already developed and debugged legacy code, but the potentially unsafe need in type cast makes then unsuitable.

—SA
 
Share this answer
 
Comments
Maciej Los 29-Mar-13 18:49pm    
Agree. +5!
Sergey Alexandrovich Kryukov 29-Mar-13 19:09pm    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900