Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: problem with dropdownlist server control


Message #1 by suresh sannasi <sureshsv@y...> on Wed, 27 Mar 2002 07:56:20 -0800 (PST)
Hi,

   I am using asp dropdownlist server control in asp
form. It always
select one of the value from the list. If I don't want
to select any
values, what should I do. I am filling dropdownlist
from table data.

   Could you please help me on that.

  Regards,
  Suresh SVS


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/
Message #2 by Neeta.Ambekar@l... on Wed, 27 Mar 2002 21:40:17 +0530
Hi
     If you are doing databound to dropdownlist control with dataset then
add blank value in  column of dataset and then bind it to dropdownlist
contorl.
hope this will help u ...

Neeta

Message #3 by Imar Spaanjaars <Imar@S...> on Wed, 27 Mar 2002 18:50:54 +0100
Hi Suresh,

You could use the Insert method of the Items collection of the DropDownBox, 
right after you have bound the data to the DropDown.

This example uses an array as a datasource, but the same is true for 
binding to a database table

         Dim arrTest(2) As String
         arrTest(0) = "Apples"
         arrTest(1) = "Oranges"
         arrTest(2) = "Bananas"
         DropDownList1.DataSource = arrTest
         DropDownList1.DataBind()
         DropDownList1.Items.Insert(0, "Make a selection")
         DropDownList1.Items(0).Value = ""

The code above will insert a new item at location 0 (the first item in the 
list) The last line resets its value to an empty string. If you leave that 
out, "Make a selection" will be submitted as the controls value.

HtH

Imar


At 07:56 AM 3/27/2002 -0800, you wrote:
>Hi,
>
>    I am using asp dropdownlist server control in asp
>form. It always
>select one of the value from the list. If I don't want
>to select any
>values, what should I do. I am filling dropdownlist
>from table data.
>
>    Could you please help me on that.
>
>   Regards,
>   Suresh SVS


Message #4 by suresh sannasi <sureshsv@y...> on Wed, 27 Mar 2002 11:27:26 -0800 (PST)
 Neeta,

  Thanks. it works

--- Neeta.Ambekar@l... wrote:
> 
> Hi
>      If you are doing databound to dropdownlist
> control with dataset then
> add blank value in  column of dataset and then bind
> it to dropdownlist
> contorl.
> hope this will help u ...
> 
> Neeta
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/

  Return to Index