Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
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 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 September 11th, 2006, 06:07 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
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
 
Old September 11th, 2006, 06:26 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
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





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 06: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





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