By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Default value in a combo box

P: n/a
I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not used.
This combo box is complex bounded.
--
L. A. Jones
Sep 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Add the select option to your data table that you are binding too.
Eg. dt.Rows.Add(new DataRow(-1, "SELECT", "some_other_column");
Then check in your validation code for selectedText = "SELECT"
(double check my property names)

Dave wrote:
I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not used.
This combo box is complex bounded.
--
L. A. Jones
Sep 27 '06 #2

P: n/a
Dave,

Although I find it an horrible solution, can you add with by instance the
DataTable LoadDataRow a datarow.

You have than to use a DataView to set the rows in the combobox in an
ordered way using the Sort.
You should than be sure that all the rows are filled in the "sort" column
and set that column in the LoadDataRow that you use for the "Select" on
spaces.

Most probably you will not succeed in that, because you want your display
member to be the sorted one.
But as you can, than this is easy. There are more ways, but are in my
opinion in fact all even more horrible if you use the value and the
displaymember.

I prefer just a label above the Combobox with in that "Select".

I hope this gives an idea,

Cor

"Dave" <Da**@discussions.microsoft.comschreef in bericht
news:D5**********************************@microsof t.com...
>I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not
used.
This combo box is complex bounded.
--
L. A. Jones

Sep 27 '06 #3

P: n/a
Or you could use InsertAt

DataTable.Rows.InsertAt(DataRow, 0)

Sep 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.