By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,662 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,662 IT Pros & Developers. It's quick & easy.

How does a dynamic control load post back data across post back??

P: n/a
As we know , the view state is not responsible for having TextBoxes,
CheckBoxes, DropDownLists, and other Web controls remember their values
across postback.

When I dynamically add a DropDownList in the web,and dynamically add the
items in it.

such as:

void Page_Load(Object sender, EventArgs e)
{
DropDownList ddlDynamic = new DropDownList();
ddlDynamic.ID = "ddlDynamic";

form1.Controls.Add(ddlDynamic);

if (!IsPostBack)
{
for (int i=1; i <=3; i++)
ddlDynamic.Items.Add(new ListItem(i.ToString(), i.ToString()));
}

I check the second value of the DropDownList.

when post back ,I can see the dynamically items,and the checked value is
what I have checked.

I know that the viewstate of the DropDownList can be loaded by the method
form1.Controls.Add(ddlDynamic) during post back,but I don't know how does the
check value be loaded during post back.
please help me.

May 25 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

gorilla wrote:
As we know , the view state is not responsible for having TextBoxes,
CheckBoxes, DropDownLists, and other Web controls remember their values
across postback.

When I dynamically add a DropDownList in the web,and dynamically add the
items in it.

such as:

void Page_Load(Object sender, EventArgs e)
{
DropDownList ddlDynamic = new DropDownList();
ddlDynamic.ID = "ddlDynamic";

form1.Controls.Add(ddlDynamic);

if (!IsPostBack)
{
for (int i=1; i <=3; i++)
ddlDynamic.Items.Add(new ListItem(i.ToString(), i.ToString()));
}

I check the second value of the DropDownList.

when post back ,I can see the dynamically items,and the checked value is
what I have checked.

I know that the viewstate of the DropDownList can be loaded by the method
form1.Controls.Add(ddlDynamic) during post back,but I don't know how does the
check value be loaded during post back.
please help me.

--->>>>"I know that the viewstate of the DropDownList can be loaded by
the method
form1.Controls.Add(ddlDynamic) during post back,"

if your checked value is already selected then what is the
problem....???

---->>>>"but I don't know how does the check value be loaded during
post back."

i dont get it loading the same control with same id did all to save
and persists the values....
if you want to do some business with the value just subscribe the
SelectedIndexChanged event of dropdown list.

Thanks
Masudur

May 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.