Problem with Autopostback

M

mo

Hi,

I have a set of Dynamic DropDownLists with AutoPostback. the problem I
have is that when I select the dropdown and the page refreshes the old
values in the text boxes disappear. Is there a way to preserve the
values?

Thanks,
Mo
 
J

Jorge Matos

Make sure you are not accidentally re-initializing your controls. All
controls have viewstate to maintain their values, and therefore in your
Page_Load event you need to make sure you only initialize your drop-downs
when the page is first being requested via HTTP GET request and not during an
HTTP POST request.

inside Page_Load:

public void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//Initialize drop downs here
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top