473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
1 2495

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mark | last post by:
I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
5
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself....
4
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
1
by: ayende | last post by:
Okay, I'm pretty sure that I'm doing everything right here, but something is very wrong in the result. I've a page that has a drop down list (with auto-post-back = true) and a place holder. ...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.