DropDownList and Databinding

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
 
E

Eliyahu Goldin

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?
 
T

Tor Inge Rislaa

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
 
D

David Wier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top