Click here to Skip to main content
15,886,788 members

Get values from dynamically added radiobuttons

NaniCh asked:

Open original thread
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

C#
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;
                        tc.Controls.Add(lblquestion);
                        tr.Controls.Add(tc);
                        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;
                            cl.Controls.Add(txt);
                            cl2.Controls.Add(raid);
                            tr.Controls.Add(cl);
                            tr.Controls.Add(cl2);
                           
                            j++;
                            k++;
                            table1.Controls.Add(tr1);
                        }
                        table1.Controls.Add(tr);

                    }
                    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..
Tags: C# (C# 4.0), ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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