473,385 Members | 1,355 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.

drop down list doesn't keep state

hi all,

I have a dropdownist that doesn't keep it's selected previous state.
When I select an item i want the selected item to be selected when the
postback happened. The DDL looks like this
<asp:DropDownList ID="keywordsDropDownList" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="keywordsDropDownList_Selec tedIndexChanged"
></asp:DropDownList>
Someone has an idea what I do wrong?

protected void AddButton_Click(object sender, EventArgs e)
{
myController = new Controller();
myTest = new Test(0, NameTextBox.Text,
DescriptionTextBox.Text);

NameLabel.Text = "Enter keywords for " + myTest.Name;
keywordsDropDownList.DataSource =
myController.GetKeywordTemplates();
keywordsDropDownList.DataValueField = "Id";
keywordsDropDownList.DataTextField = "KeywordParameter";
keywordsDropDownList.DataBind();

MultiView1.SetActiveView(KeywordView);
}

When the dropdownbox selection is changed:
protected void keywordsDropDownList_SelectedIndexChanged(object sender,
EventArgs e)
{
AddButton_Click(sender, e);
}

Oct 6 '06 #1
1 1646
What does you Page_Load look like? A common reason for losing state is
refresh in every page load. Events (button, etc.) run AFTER Page_Load().

Are you using viewstate or is it turned off? If off, you will NOT hold state
even if you fix item #1 (if it is set up incorrectly).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
<ta******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
hi all,

I have a dropdownist that doesn't keep it's selected previous state.
When I select an item i want the selected item to be selected when the
postback happened. The DDL looks like this
<asp:DropDownList ID="keywordsDropDownList" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="keywordsDropDownList_Selec tedIndexChanged"
>></asp:DropDownList>

Someone has an idea what I do wrong?

protected void AddButton_Click(object sender, EventArgs e)
{
myController = new Controller();
myTest = new Test(0, NameTextBox.Text,
DescriptionTextBox.Text);

NameLabel.Text = "Enter keywords for " + myTest.Name;
keywordsDropDownList.DataSource =
myController.GetKeywordTemplates();
keywordsDropDownList.DataValueField = "Id";
keywordsDropDownList.DataTextField = "KeywordParameter";
keywordsDropDownList.DataBind();

MultiView1.SetActiveView(KeywordView);
}

When the dropdownbox selection is changed:
protected void keywordsDropDownList_SelectedIndexChanged(object sender,
EventArgs e)
{
AddButton_Click(sender, e);
}

Oct 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
2
by: Jeff Thur | last post by:
I am running a SQL Stored Procedure that will give the user a count of how many records are in the database as per certain criteria. I'm using the Execute Scalar Method. I have no problem passing...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already...
5
by: Ajith Menon | last post by:
I need to select multiple entries in the drop down list. E.g. Search a string in languages like C#, VB, Java etc. These entries are in drop down. So i need to multi select to search in multiple...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
8
by: dskanth | last post by:
I have 4 drop down lists, namely Location, country, State and City. Ex: Location: Asia, Country: India, State: Andhra Pradesh, City: Hyderabad. If i select any option in the Location drop down...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.