|
 |
aspx_beginners thread: Dropdownlist Blank First Item
Message #1 by jude@j... on Mon, 18 Feb 2002 00:53:25
|
|
I am finding the simplest things to do in vanilla HTML/ASP now take only
hours and days to do with ASP .Net.
In the VS .Net IDE, I am populating a dropdownlist with data from a
table. I want to add to that list a "" with a value of 9999, that is, I
don't want any item from the database pre-selected when the .aspx page
loads.
I have tried adding
<asp:ListItem Value="9999" Text=" " Selected="True"> </asp:ListItem>
as well as
<asp:ListItem Value="9999" Text="" Selected="True"></asp:ListItem>
between the <asp:DropDownList> tags in the HTML page. That does nothing.
No blank item is added.
I also tried adding an item (" ") to the dropdownlist's Item collection
ter the DataBind() method is executed in the odeehind page. This put a
blank line in the box, but it puts if AFTER the table data; it is not the
selected item.
Can anyone point me in the right direction? This takes 12 seconds to do
the "old" way.
Thanks!
jk
Message #2 by jude@j... on Mon, 18 Feb 2002 01:29:53
|
|
I discovered the answer to my own above question. Thanks anyway.
I added:
myDropdownlist.Selecteditem.Text = ""
myDropdownlist.Selecteditem.Value = "9999"
to the codebehind page.
Message #3 by "Steven A Smith" <ssmith@a...> on Sun, 17 Feb 2002 20:25:46 -0500
|
|
You need to use the Insert method. Check out these articles for more on
this and other tricks with drop down lists:
http://aspalliance.com/search/default.asp?keyword=drop+down+list
Steve
Steven Smith, MCSE+Internet, Microsoft MVP: ASP.NET
ssmith@a...
President, ASPAlliance.com
http://aspalliance.com The #1 ASP.NET Community
http://aspsmith.com ASP.NET Training for ASP Developers
Learning ASP.NET? Get My Book: ASP.NET By Example
http://www.amazon.com/exec/obidos/ASIN/0789725622/stevenatorasp/
----- Original Message -----
From: <jude@j...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Monday, February 18, 2002 12:53 AM
Subject: [aspx_beginners] Dropdownlist Blank First Item
> I am finding the simplest things to do in vanilla HTML/ASP now take only
> hours and days to do with ASP .Net.
>
> In the VS .Net IDE, I am populating a dropdownlist with data from a
> table. I want to add to that list a "" with a value of 9999, that is, I
> don't want any item from the database pre-selected when the .aspx page
> loads.
>
> I have tried adding
>
> <asp:ListItem Value="9999" Text=" " Selected="True"> </asp:ListItem>
> as well as
> <asp:ListItem Value="9999" Text="" Selected="True"></asp:ListItem>
>
> between the <asp:DropDownList> tags in the HTML page. That does nothing.
> No blank item is added.
>
> I also tried adding an item (" ") to the dropdownlist's Item collection
> ter the DataBind() method is executed in the odeehind page. This put a
> blank line in the box, but it puts if AFTER the table data; it is not the
> selected item.
>
> Can anyone point me in the right direction? This takes 12 seconds to do
> the "old" way.
>
> Thanks!
>
> jk
>
$subst('Email.Unsub').
>
Message #4 by jude@j... on Mon, 18 Feb 2002 18:17:30
|
|
Steve,
What I thought was a solution didn't work. Your direction to the
ASPAlliance web site did give me what I was looking for.
Thank you!!!
I owe you a beer; I may even buy your book!
Thanks a ton!
jk
|
|
 |