views:

23

answers:

1

I have a Webcontrol, that I create completely dynamically and it contains radiobuttonList. How can I acces this radibuttonlist values, on pages where I register this control?

public class MyControl: WebControl

  pnContainer = new Panel();
  rbl = new RadioButtonList();
  liResume = new ListItem("Resume", "Resume");
  liReopen = new ListItem("ReOpen", "ReOpen");
  rbl.Items.Add(liResume); 
  rbl.Items.Add(liReopen); 

  pnContainer.Controls.Add(lblReOpenTitle);
  pnContainer.Controls.Add(rbl);
  this.Controls.Add(pnContainer);
A: 

As always exist 2 ways:

  1. Just ensure that after postback you have recreated your radibuttonlist. Then using FindControl locate this list and get back your data
  2. You can directly access data passed from client with help of Request.Form, but in this case you need to know real name of radibuttonlist (see Control.UniqueID property)
Dewfy