Getting Values of Dynamically Created Controls.

When you want to get a value of a dynamically created control, you need to create the control again while postback.

——————————————————-
for example:

protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
createDynamicDDL();
}

private void createDynamicDDL()
{
DropDownList ddl_1 = new DropDownList();
tc.add(ddl_1);  // TableCell(Let’s say tc already exist.)
tr.add(tc);
tbl.add(tr);
}

——————————————————-

Unless you don’t do this, NullReferenceException will be occurred.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: