Click here to Skip to main content
11,929,249 members (65,195 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# 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 21: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 29-Mar-13 7:41am
can you please send me sample code...?
V. 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.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