Radiobutton list and array

Posted by Anweshabhowmick under ASP.NET on 9/24/2010 | Points: 10 | Views : 2787 | Status : [Member] | Replies : 2
How radiobutton list value can be store in a array......

the how it cane be store in a database or a label.......




Responses

Posted by: SheoNarayan on: 9/24/2010 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
You can do this by using following code snippet

object[] ar = new ArrayList(RadioButtonList1.Items).ToArray();


You will need to use System.Collections; namespace.

To print it on the page, write below code snippet

foreach (object o in ar)

{
Response.Write(o.ToString());
}


In the same way you can store (print) into Label or database.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Anweshabhowmick, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nisar87 on: 9/24/2010 [Member] Starter | Points: 25

Up
0
Down
ArrayList radioButtons = new ArrayList();

foreach (Control ctl in this.Controls)
{
RadioButton btn = ctl as RadioButton;
if (btn != null) radioButtons.Add(btn);
}
this._radioButtonArray =
(RadioButton[])radioButtons.ToArray(typeof(RadioButton));


you can store to database by simply iterate again through ArrayList

_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Anweshabhowmick, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response