473,385 Members | 1,312 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,385 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 2234
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
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.