Click here to Skip to main content
11,641,064 members (56,898 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
Hi experts
i did adding radio buttons dynamically in a table. then how can i get checked radio button values in that table

here i post my ocde

int j = 0;
            int k = 0;
            string l = "0";
            foreach (var q in MyList)
                if (q.OptionGroup == "Radio Buttons")
                        TableRow tr = new TableRow();
                        tr.Font.Bold = true;
                        TableCell tc = new TableCell();
                        Label lblquestion = new Label();
                        tc.Height = 10;
                        lblquestion.Text = q.Name;
                        for (int i = 0; i < Mylist.Length; i++)
                            TableRow tr1 = new TableRow();
                            TableCell cl = new TableCell();
                            TableCell cl2 = new TableCell();
                            Label txt = new Label();
                            txt.Text = AnswerName;
                            txt.ID = "Lableanswer" + k;
                            cl.Height = 10;
                            cl2.Height = 10;
                            RadioButton raid = new RadioButton();
                            raid.ID = "raid" + j;
                            raid.GroupName = l;
                    l = l + 1;

here we have multiple radiobutton in each row.. how can i get checked radio button values in each row..

please help me..

Thanks in advance..
Posted 28-Mar-13 20:06pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Basically there are two ways:

Loop the table, check the cell that contains the radiobutton to see if it is checked or not.

Add an event handler to the radiobutton on creation (the same handler for each radiobutton).

raid.Clicked += ... 

When clicked, the sender object can be casted to a RadioButton object ("unboxed") and the value updated in a list of some kind. (eg. Dictionary<string,> where string is the button name)
NaniCh at 29-Mar-13 7:41am
can you please send me sample code...?
V. at 29-Mar-13 8:10am
You should be able to deduce the code from the tips I gave you. I would send code if I had a sample lying around, but I would have to write one from scratch myself.

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

  Print Answers RSS
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 145
4 Afzaal Ahmad Zeeshan 129
0 Mika Wendelius 380
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 125
4 Afzaal Ahmad Zeeshan 89

Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100