Solved

DropdownList Does not remember value

Posted on 2010-09-01
2
324 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-
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now