I'm databinding my DropDownList to a DataSet. How do I add a dummy record
at the top of the combo box.
In other words, suppose we are dealing with cars I want something like:
<select name="cboCars">
<option value="0">Select a car</option>
<option value="1">Ford Mustang</option>
....
<option value="5">Mitsubishi Eclipse</option>
</select>
How do I get the "Select a car" option at the top, while still databinding
the DropDownList?
If I don't have the dummy record the DropDownList auto selects the first
option as the default, which isn't good for my purpose.
Thanks in advance,
Dan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003 4 1294
*After* you databind, do a dropdownlist.items.add(0, "")
HTH,
Morgan
"Dan" <dh******@somewhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I'm databinding my DropDownList to a DataSet. How do I add a dummy record at the top of the combo box.
In other words, suppose we are dealing with cars I want something like:
<select name="cboCars"> <option value="0">Select a car</option> <option value="1">Ford Mustang</option> ... <option value="5">Mitsubishi Eclipse</option> </select>
How do I get the "Select a car" option at the top, while still databinding the DropDownList?
If I don't have the dummy record the DropDownList auto selects the first option as the default, which isn't good for my purpose.
Thanks in advance, Dan
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003
This is assuming you are binding via code i.e. dropdownlist.datasource =
mydataset.tables(0)
I've never done visual databinding in the WebForm designer, but you should
be able to add the dropdownlist.items.insert(0, "") (sorry, chose the wrong
method from memory) on the page_load event.
--Morgan
"Morgan" <mf****@spamcop.net> wrote in message
news:uZ**************@tk2msftngp13.phx.gbl... *After* you databind, do a dropdownlist.items.add(0, "")
HTH,
Morgan "Dan" <dh******@somewhere.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I'm databinding my DropDownList to a DataSet. How do I add a dummy
record at the top of the combo box.
In other words, suppose we are dealing with cars I want something like:
<select name="cboCars"> <option value="0">Select a car</option> <option value="1">Ford Mustang</option> ... <option value="5">Mitsubishi Eclipse</option> </select>
How do I get the "Select a car" option at the top, while still
databinding the DropDownList?
If I don't have the dummy record the DropDownList auto selects the first option as the default, which isn't good for my purpose.
Thanks in advance, Dan
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003
Worked like a charm. I knew it had to be something simple that I was
missing.
Thanks,
Dan
"Morgan" <mf****@spamcop.net> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl... This is assuming you are binding via code i.e. dropdownlist.datasource = mydataset.tables(0) I've never done visual databinding in the WebForm designer, but you should be able to add the dropdownlist.items.insert(0, "") (sorry, chose the
wrong method from memory) on the page_load event.
--Morgan "Morgan" <mf****@spamcop.net> wrote in message news:uZ**************@tk2msftngp13.phx.gbl... *After* you databind, do a dropdownlist.items.add(0, "")
HTH,
Morgan "Dan" <dh******@somewhere.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... I'm databinding my DropDownList to a DataSet. How do I add a dummy record at the top of the combo box.
In other words, suppose we are dealing with cars I want something
like: <select name="cboCars"> <option value="0">Select a car</option> <option value="1">Ford Mustang</option> ... <option value="5">Mitsubishi Eclipse</option> </select>
How do I get the "Select a car" option at the top, while still databinding the DropDownList?
If I don't have the dummy record the DropDownList auto selects the
first option as the default, which isn't good for my purpose.
Thanks in advance, Dan
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003
after you bound the DropDownList
call:
ddl.Items.Insert(0,new ListItem("Select a car","0"));
"Dan" <dh******@somewhere.com> дÈëÓʼþ
news:%2****************@TK2MSFTNGP09.phx.gbl... I'm databinding my DropDownList to a DataSet. How do I add a dummy record at the top of the combo box.
In other words, suppose we are dealing with cars I want something like:
<select name="cboCars"> <option value="0">Select a car</option> <option value="1">Ford Mustang</option> ... <option value="5">Mitsubishi Eclipse</option> </select>
How do I get the "Select a car" option at the top, while still databinding the DropDownList?
If I don't have the dummy record the DropDownList auto selects the first option as the default, which isn't good for my purpose.
Thanks in advance, Dan
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tobias Froehlich |
last post by:
Hi!
I have a very newbie-ish question:
When I have a comboBox on my form, how can I set it so that the user
cannot edit the elements that are selectable in that comboBox? By
standard the user...
|
by: Dominic |
last post by:
Hi guys,
I'm not sure if this question belongs to FAQ, but I couldn't find a
concrete answer.
I created a Datagrid control using ItemTemplate, but it's NOT a
in-place editing datagrid. One of...
|
by: Guedj54 |
last post by:
Is it possible to display more than 11 items ( without having to
scroll down ) in an dropdownlist.
Thanks
S
|
by: jimb |
last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I
can't read it.
Anybody have a working example of a dropdownlist in an editable grid?
Thanks.
--
.....
|
by: Bernie Yaeger |
last post by:
Everyone misses the point on this - what we need is a combobox autocomplete
that is a dropdownlist only. When in dropdown mode, you can enter text -
making that autocomplete is trivial. But when...
|
by: Joe Schmoe |
last post by:
All I want to to be able to take a two-column DataReader (One column with
the Item ID number, the other with Item Description text) and load it into a
Windows Forms ComboBox (Set to DropDownList...
|
by: Mark Rae |
last post by:
Hi,
Just looking for some v2 guidance here...
In WebForms, the DropDownList control has an Items collection which contains
ListItem objects which, in turn, very conveniently contain a text...
|
by: RSH |
last post by:
I have a simple question regarding inheritance in a web form.
I have a DropDownList in an aspx form. It is called DropDownList1
I have a class that will be overriding the render event so I...
|
by: Brett |
last post by:
I have a DropDownList in an ASP.NET web form that is populated with items
from a lookup table by binding that DropDownList to a SqlDataSource.
However, the items in the lookup table can change over...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |