?
Solved

DropdownList Does not remember value

Posted on 2010-09-01
2
Medium Priority
?
331 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 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