the berserker
the berserker

Reputation: 1594

reading values from dynamically created Webcontrol

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);

Upvotes: 1

Views: 208

Answers (1)

Dewfy
Dewfy

Reputation: 23624

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)

Upvotes: 1

Related Questions