Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
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 March 10th, 2004, 01:43 PM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default Adding an element to a binded DropDownlist

I have a Dropdownlist whose data I bind from a Database table.
No problems with that.
But I want to add a seperate item "Select a category" at the head of
the list. How am I supposed to do so ?

__________________
-.. -..
 
Old March 10th, 2004, 03:09 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

DropDownList.Items.Insert(0, New ListItem("Select a category", ""))
 
Old March 10th, 2004, 03:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

After you bind your data add the following code:

ddl.Items.Insert(0, "1st Item")

"ddl" is the name of your dropdownlist, "0" is the index value, "1st Item" is what you want added to the list.

J
 
Old March 10th, 2004, 03:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Well, it looks like planoie beat me to it...

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Problem in adding the new element into the XML fil Somesh C# 3 February 6th, 2007 06:41 AM
adding options to a select element dymanicly StevesonD Javascript How-To 0 September 28th, 2006 09:53 AM
Adding a new Element monuindia2002 XML 2 March 13th, 2006 11:59 PM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM





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