473,651 Members | 2,536 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Selecte dText = dr["descriptio n"].ToString(); //there is only one
item here. is this the best way to iterate?
}

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

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

cmbType.Selecte dText = dr["descriptio n"].ToString();
Nov 15 '05 #1
2 2251
Try
cmbType.Selecte dValue=...

Regards
Dan Cimpoiesu

"drishtik" <sh*****@hotmai l.com> wrote in message
news:OW******** *****@tk2msftng p13.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.Selecte dText = dr["descriptio n"].ToString(); //there is only one
item here. is this the best way to iterate?
}

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

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

cmbType.Selecte dText = dr["descriptio n"].ToString();

Nov 15 '05 #2
cmbType.Items.F indByText(dr["descriptio n"].ToString()).Se lected = True

idog

"Dan Cimpoiesu" <da**********@g mx.net> wrote in message
news:#u******** ******@TK2MSFTN GP09.phx.gbl...
Try
cmbType.Selecte dValue=...

Regards
Dan Cimpoiesu

"drishtik" <sh*****@hotmai l.com> wrote in message
news:OW******** *****@tk2msftng p13.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.Selecte dText = dr["descriptio n"].ToString(); //there is only one item here. is this the best way to iterate?
}

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

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

cmbType.Selecte dText = dr["descriptio n"].ToString();


Nov 15 '05 #3

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

Similar topics

8
12088
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 combobox. What is the solution? Thank you in advance.
1
2492
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 DataTable("table"); testTable.Columns.Add("Col1", typeof(Int32)); testTable.Columns.Add("Col2", typeof(String)); testTable.Rows.Add(testTable.NewRow());
3
6821
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: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
0
407
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 corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
30
4566
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 corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8694
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8571
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4280
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.