Solved

DropdownList Does not remember value

Posted on 2010-09-01
2
329 Views
Last Modified: 2012-05-10
I've got a dropdownlist that is initialised like this:

 
private void getContactTypeList ()
	{
		ArrayList ContactArrayList = new ArrayList ();
		ContactArrayList.Add ("Email");
		ContactArrayList.Add ("Telephone");
		ddContact.DataSource = ContactArrayList;
		ddContact.DataBind ();
	}

Open in new window


The front end looks like this:

 
<asp:DropDownList                       
                        ID="ddContact"
                        runat="server"/>

Open in new window


When the form it is within is posted, the drop down does not remember its previous setting if it does not validate, how can I get it to remember its state?

Darren
0
Comment
Question by:darren-w-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 33574893
You should bind the dropdownlist item on page_load like this..

 

if (!IsPostBack)
{
//page loads first time
// Bind the dropdownlist here
}
else
{
// when the page loads second or more time execute code here
}
0
 
LVL 13

Author Closing Comment

by:darren-w-
ID: 33575010
Thanks, that did the trick
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question