DropDownList and Databinding

  • Thread starter Thread starter Tor Inge Rislaa
  • Start date Start date
T

Tor Inge Rislaa

DropDownList and Databinding



I have a DropDownList on my WebFrom, bound to a data source. When the form
is loaded the first Item in the list of the control is selected by default.
Is there a line of code that can prevent any item to be selected initially.



TIRislaa
 
You can set SelectedIndex=-1. Note, that the first item still will be
visible, it just won't be selected. Is that what you want?
 
Yes Thank You, but I also want the text property to be "", if it is possible
TIRislaa

Eliyahu Goldin said:
You can set SelectedIndex=-1. Note, that the first item still will be
visible, it just won't be selected. Is that what you want?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


Tor Inge Rislaa said:
DropDownList and Databinding



I have a DropDownList on my WebFrom, bound to a data source. When the
form
is loaded the first Item in the list of the control is selected by default.
Is there a line of code that can prevent any item to be selected initially.



TIRislaa
 
No problem there - just after the databinding -
MyDDL.items.insert(0,"")

or, if you're using ASP.Net 2.0 - just set the 'ApendDataBoundItems'
property to 'True' - then, add that blank item in the items property of the
DDL
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com


Tor Inge Rislaa said:
Yes Thank You, but I also want the text property to be "", if it is possible
TIRislaa

"Eliyahu Goldin" <[email protected]> skrev i melding
You can set SelectedIndex=-1. Note, that the first item still will be
visible, it just won't be selected. Is that what you want?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


Tor Inge Rislaa said:
DropDownList and Databinding



I have a DropDownList on my WebFrom, bound to a data source. When the
form
is loaded the first Item in the list of the control is selected by default.
Is there a line of code that can prevent any item to be selected initially.



TIRislaa
 
Back
Top