Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2004, 11:02 AM
Authorized User
 
Join Date: Jul 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem about asp:DropDownList control

I have designed a web form and use the <asp:dropdownlist> control.I assigned some codes in the onSelectedIndexChanged Event.After I test it .I found that the first item in the list will not fired the event. I have to chose other item then went back to chose the first item then it would work.I try to correct it by setting the selectedindex to -1 at the first load of the form but it don't work.And try to assign some code in the code in the condition if(! IsPostBAck) .It is still not work. The reson of this problem is the first time the form loaded the selectedindex will be 0.So if I select this item the onSelectedIndexCHanged will not fire.So nothing happen.
          So if you have a trick to correct this annoying problem.Please tell me.Thank you in advance.
                                                                  Doctorsom


 
Old July 27th, 2004, 11:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

The reason is there has to be a default. If no item selected, then the first one on the list is selected. You can rectify this by adding an entry such as:

<asp:ListItem Value="">Select an Item</asp:ListItem>

However, you have to make sure that if they select an item then select this again, that it doesn't cause an error.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList problem as DataGrid Control param99 ASP.NET 1.0 and 1.1 Professional 1 November 23rd, 2006 12:18 PM
ASP.NET 1.1 dropdownlist problem jjduran ASP.NET 2.0 Basics 1 July 16th, 2006 11:11 PM
ASP.NET 1.1 dropdownlist problem jjduran ASP.NET 2.0 Basics 0 July 9th, 2006 07:04 PM
selected value from dropdownlist control netwizard_01 ASP.NET 1.0 and 1.1 Basics 3 January 20th, 2004 09:29 AM
DropDownList control bmains ASP.NET 1.0 and 1.1 Basics 4 November 21st, 2003 01:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.