PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?Z29yaWxsYQ==?=
Guest
Posts: n/a
 
      25th May 2007
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.

 
Reply With Quote
 
 
 
 
Masudur
Guest
Posts: n/a
 
      25th May 2007

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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
page load/post back rjl Microsoft ASP .NET 3 5th Jan 2006 08:56 AM
How to use a dynamic text link as a post-back trigger? darrel Microsoft ASP .NET 1 28th Jan 2005 12:56 AM
Post Back on Web User Control =?Utf-8?B?QnJ5YW4=?= Microsoft ASP .NET 1 29th May 2004 07:21 PM
Refresh data grid control without (post back) =?Utf-8?B?QWxla3NhbmRhciBBbmRqZWxrb3ZpYw==?= Microsoft ASP .NET 1 24th May 2004 02:17 PM
Post Back Function Name and Dynamic Form ID Kevin Phifer Microsoft ASP .NET 9 11th Nov 2003 02:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:59 PM.