Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 11th, 2006, 06:07 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Default Clearing the Dregs from a Dropdown menu

Hi All

I have 2 dropdown menus that are databound. The second dropdown list is bound to the first dropdown menu's selectedvalue.

I have created the databinding within the code behind for various reasons and for some reason when selecting a different value from within my first menu, the second menu updates accordingly but still stores the previous items too rather than refreshing and just storing the new selected data.

When I set up the databinding using SQLDatasource controls the second list updates without storing the dregs.

Please could anyone let me know what I could be missing...
Code:
Protected Sub Menu1_SelectedIndexChanged
     (ByVal sender As Object, ByVal e As System.EventArgs)

        'database connection class/ function
        Dim Menu2Populate As New dbclass()
 
        Menu2Populate.Sproc = "strored procedure"
        Menu2Populate.CustomerID = Menu1.SelectedValue
        Menu2.DataSource = Menu2Populate.RetrieveMenu2data
        Menu2.DataBind()

    End Sub
Many thanks

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
Reply With Quote
  #2 (permalink)  
Old September 11th, 2006, 06:26 AM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI All

I figured out a solution if anyone is interested...

What I did was used Menu2.Items.Clear() prior to calling my databind.

Code:
Protected Sub Menu1_SelectedIndexChanged
     (ByVal sender As Object, ByVal e As System.EventArgs)

       Menu2.Items.Clear() 

        'database connection class/ function
        Dim Menu2Populate As New dbclass()
 
        Menu2Populate.Sproc = "strored procedure"
        Menu2Populate.CustomerID = Menu1.SelectedValue
        Menu2.DataSource = Menu2Populate.RetrieveMenu2data
        Menu2.DataBind()

    End Sub
Basically clears the menu before populating again.

If there is a better way of treating this please feel free to educate me.

Thanks

Rit
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting DropDownList dropdown menu size aliadil793 .NET Framework 1.x 0 May 20th, 2008 07:05 AM
Selected value from dropdown menu wont display. mizjinx Classic ASP Databases 0 May 20th, 2007 08:24 PM
Urgent help in dropdown menu vigneshb4u BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 January 10th, 2006 05:29 PM
Javascript Dynamic dropdown Menu itHighway Javascript How-To 0 July 24th, 2005 10:53 PM
dropdown menu population with ONCHANGE YoungLuke JSP Basics 1 September 25th, 2003 02:46 PM



All times are GMT -4. The time now is 02:40 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.