Dynamiclly radiobuttonlist
-
Hey I have created a metode to create RadiobuttonList dynamically but when i show it in my page end i chec them to false or true and when i click the button all radiobutton is coming back to true. I have a function to read wgat user have selected : Hope i can help. her is som code to create radiobuttonlist: foreach (DataRow dr in ds.Tables[0].Rows) { Label li = new Label(); System.Web.UI.WebControls.ListItem ls = new System.Web.UI.WebControls.ListItem(); RadioButtonList rl = new RadioButtonList(); rl.Items.Add(new System.Web.UI.WebControls.ListItem("Inkl", dr["Type"].ToString())); rl.Items.Add(new System.Web.UI.WebControls.ListItem("Eks", dr["Type"].ToString())); rl.RepeatDirection = RepeatDirection.Horizontal; Panel2.Controls.Add(li); Panel2.Controls.Add(rl); //tilføjer dem til panelet } then when i click a button hwo called checkthevalue, i called this metode: foreach (Control cr in Panel2.Controls) { if (cr is RadioButtonList) { RadioButtonList rb = (RadioButtonList)cr; foreach (System.Web.UI.WebControls.ListItem ls in rb.Items) { if (ls.Selected && rb.SelectedItem.Text == "Eks") { //this ad a line to pdf file document.Add(new Paragraph("-" + rb.SelectedItem.Value.ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12))); } } } } Hope i can help me.