Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 October 29th, 2005, 10:31 PM
Authorized User
Join Date: Oct 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Update a DropDownListBox

I want my dropdownlistbox to show the new item just entered from the database once the user clicks the update(save) button. I exactly don't know what is the exact property or method for dropdownlistbox since im a beginner in .Net.

Here is my code to get a better understanding:

Sub SaveNewSubCat(sender as object,e as EventArgs)

Dim strConn as String = "Database=watal;server=Maxood;User id=sa;password=;"
        Dim objConn as New SqlConnection(strConn)
        Dim cmdInsertSubCat as New SqlCommand("sp_SaveNewSubCat",objConn)

        cmdInsertSubCat.CommandType = CommandType.StoredProcedure

        cmdInsertSubCat.Parameters.Add("@SubCatName",txtNe wSubCat.Text)
        cmdInsertSubCat.Parameters.Add("@CatName",cboCat.S electedItem.Text)


        lblNewSubCat.Visible = "false"
        txtNewSubCat.Visible = "false"
        lblNewSubCat.Visible = "false"
        txtNewSubCat.Visible = "false"

    End If
End Sub

Could some tell me what to do here?

Old October 31st, 2005, 04:06 AM
Authorized User
Join Date: Jul 2005
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts

Two ways:

(*) Postback to the server Save the value to the database and rebind the dropdown.

(*) Add the new value using JavaScript options object and then use an XmlHttpRequest to save the new value to the database. Using option (2), a roundtrip can be avoided.

Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/
I Blog At: http://deepak.blogdrive.com/ and http://deepakvasudevan.blogspot.com/

Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple columns in an update statement debbiecoates SQL Server 2000 1 August 17th, 2008 04:01 AM
displying values in dropdownlistbox imjayakumar Crystal Reports 2 April 3rd, 2007 07:19 AM
Update link doesn't update in FormsView shaly ASP.NET 2.0 Basics 0 December 6th, 2006 04:33 PM
dropdownlistbox and menu ksh_raj General .NET 0 March 14th, 2006 05:03 AM
Datagrid.update() and DataAdapter.Update aarunlal ASP.NET 2.0 Professional 2 February 23rd, 2006 11:41 PM

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