473,408 Members | 1,826 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,408 software developers and data experts.

Trouble getting selected Index from dropdownlist bound to datareader.

Fairly Complicated Problem:
1. I have a C# web application.
2. I have a web form with 3 drop down list controls and
other text box controls for updating user information.
3. There is a submit button.
4. On the page_load of the webform I databind three
dropdownlist controls to a different datareaders.

Results:
1. When I run the page displays correctly with the
dropdown lists populated with the items from the DB.
2. I can make different selections in the dropdownlists.
3. When I click the submit button is where I have
problems.

Where I am at:
1. I can get the changed values for all of the textboxes.
2. I cannot get the values I chose in the dropdownlists.
3. The selectedIndexes of the dropdownlists remain at
whichever value I initialize them to.
4. I added an event handler to capture the SelectedIndex
Change event to see its value. This event fires but the
selectedIndex does not change. Also this event fires
before the submit.Click event handler fires.

Help

Billy Jacobs

When I click submit
3. There is no code behind page. All programmatic
functions are in a Control which it References.

Jul 21 '05 #1
2 1667
Hi Billy,

Thanks for your post. As I understand, the problem you are facing is that
you can not get the newly selected item in te dropdownlist in server code.
Please correct me if there is misunderstanding. Based on my experience, I
believe that the dropdownlist control does not post back the data to
server. I'd like you check the following issue:

1. Make sure the "AutoPostBack" property of the dropdownlist is set to True.
2. Do not bind the controls in the Page_Load method if it is postback.
Please refer to the followign code:

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
//databind three dropdownlist controls here
}
}

Please let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
You are correct about my problem and the solution.
However I don't need to set autopostback = true. Only
need to NOT databind if IsPostBack.

Billy Jacobs
-----Original Message-----
Hi Billy,

Thanks for your post. As I understand, the problem you are facing is thatyou can not get the newly selected item in te dropdownlist in server code.Please correct me if there is misunderstanding. Based on my experience, Ibelieve that the dropdownlist control does not post back the data toserver. I'd like you check the following issue:

1. Make sure the "AutoPostBack" property of the dropdownlist is set to True.2. Do not bind the controls in the Page_Load method if it is postback.Please refer to the followign code:

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
//databind three dropdownlist controls here
}
}

Please let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #3

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

Similar topics

2
by: huzz | last post by:
How do i make a dropdownlist selected value based on the value i retrive from the database. Basically i have an edit page and like to display the default value in a dropdown list from the...
4
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
3
by: Dica | last post by:
if i manually populate a dropDownList, post the page, and then fetch the selected index, i'm able to get values other than 0. however, when i bound my dropDownList to a dataReader object, even...
4
by: Joe Schmoe | last post by:
All I want to to be able to take a two-column DataReader (One column with the Item ID number, the other with Item Description text) and load it into a Windows Forms ComboBox (Set to DropDownList...
2
by: Billy Jacobs | last post by:
Fairly Complicated Problem: 1. I have a C# web application. 2. I have a web form with 3 drop down list controls and other text box controls for updating user information. 3. There is a submit...
10
by: Phuff | last post by:
Thanks in advance! I'm trying to maintain a dl list's selected index on postback. What I'm doing is when a person selects an item from the drop down list I select a date in a calendar control and...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.