473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

combobox problem

hi
i have a combobox which has some values loaded in it
like (eg)
a
b
c
d
i want to retrieve the value from the database (a, or b or c or d)
and then select that item in the combo according ly

foreach (DataRow dr in recs)
{
cmbType.SelectedText = dr["description"].ToString(); //there is only one
item here. is this the best way to iterate?
}

but this doesnt work
dr["description"] has the correct value ie b . and i want to select b in
the combo

i tried combo.selectedvalue and selectedtext but they dont work.
why and how do i solve this?

cmbType.SelectedText = dr["description"].ToString();
Nov 15 '05 #1
2 2235
Try
cmbType.SelectedValue=...

Regards
Dan Cimpoiesu

"drishtik" <sh*****@hotmail.com> wrote in message
news:OW*************@tk2msftngp13.phx.gbl...
hi
i have a combobox which has some values loaded in it
like (eg)
a
b
c
d
i want to retrieve the value from the database (a, or b or c or d)
and then select that item in the combo according ly

foreach (DataRow dr in recs)
{
cmbType.SelectedText = dr["description"].ToString(); //there is only one
item here. is this the best way to iterate?
}

but this doesnt work
dr["description"] has the correct value ie b . and i want to select b in
the combo

i tried combo.selectedvalue and selectedtext but they dont work.
why and how do i solve this?

cmbType.SelectedText = dr["description"].ToString();

Nov 15 '05 #2
cmbType.Items.FindByText(dr["description"].ToString()).Selected = True

idog

"Dan Cimpoiesu" <da**********@gmx.net> wrote in message
news:#u**************@TK2MSFTNGP09.phx.gbl...
Try
cmbType.SelectedValue=...

Regards
Dan Cimpoiesu

"drishtik" <sh*****@hotmail.com> wrote in message
news:OW*************@tk2msftngp13.phx.gbl...
hi
i have a combobox which has some values loaded in it
like (eg)
a
b
c
d
i want to retrieve the value from the database (a, or b or c or d)
and then select that item in the combo according ly

foreach (DataRow dr in recs)
{
cmbType.SelectedText = dr["description"].ToString(); //there is only one item here. is this the best way to iterate?
}

but this doesnt work
dr["description"] has the correct value ie b . and i want to select b in the combo

i tried combo.selectedvalue and selectedtext but they dont work.
why and how do i solve this?

cmbType.SelectedText = dr["description"].ToString();


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
0
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.