473,385 Members | 1,676 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.

How to command/set a databound combobx's SelectedItem

JnrJnr
88
Hi, I have a combobox that is databound. It displays all the cities. Its DisplayMember is "City" and its ValueMember is "CityID"
At runtime I am trying to change the SelectedItem.
Expand|Select|Wrap|Line Numbers
  1. Combobox.SelectedItem = "London";
I know the combobx's items is a representation of rows in the database (System.Data.DataRowView).
How can I do this so that when I use Combobox.SelectedItem = "London", that it does not just return System.Data.DataRowView but give me the value of London.
Is this possible with a databound combobox?
It works with a none-databound combobox.

Please help me!
May 9 '11 #1

✓ answered by JnrJnr

I found a solution to my problem. I dont know if this is good practise but what I did was use
Expand|Select|Wrap|Line Numbers
  1. Combobox.Text = "London"
This works both for a combobox with a dropdownstyle of "dropdownlist" and "simple".
The selected value is also correct in 'relation' to the Text.

1 1962
JnrJnr
88
I found a solution to my problem. I dont know if this is good practise but what I did was use
Expand|Select|Wrap|Line Numbers
  1. Combobox.Text = "London"
This works both for a combobox with a dropdownstyle of "dropdownlist" and "simple".
The selected value is also correct in 'relation' to the Text.
May 9 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: anastasia | last post by:
I have the following code (this is a snippet): InitDBConn(); OpenDBConnection(); OleDbCommand cmdRidge = new OleDbCommand("SELECT * FROM TRDRidgeTypes", oleDbConn); OleDbDataReader...
1
by: Rod Snyder | last post by:
I'm trying to figure out how to set the selected item of databound radiolistbutton once they are in a repeater (i.e. I want one item pre-selected instead of nothing selected). In the html there is...
5
by: Niggy | last post by:
I think I'm missing an execute command here. Please help. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
2
by: cider123 | last post by:
I have a SqlDataSource bound to a DropDownList Combo. Works just fine. I noticed 2 properties you can set in the DropDownList, 1 for the value to be displayed in the "Text" column and 1 for the...
0
by: Matt C. | last post by:
If I databind a DataTable to a dropdown list in Winforms, the SelectedItem is actually the entire DataRow from the datatable. If I want to access columns that were not part of the display, I can...
2
by: paruljain1978 | last post by:
Hi, I have written a simple code in VB.NET and using MSACCESS. 1-Try sqlstr = "INSERT INTO acbill (acbillno,acbilldate,amt,type,drawnby,status,amtremain,designation) VALUES ('" &...
3
by: Jerry | last post by:
Hi I have a combo box that is populated by an ole db connection to a ms access table (Valuewave). The column that is used in the table is called waves. The combo box is populated with the...
1
by: weiwei | last post by:
http://thumbnails.freeimagehost.eu/143/42ba7b1422405.gif Hi, I have the auto generated dayName and date out... mean the top 2 rows out but now i need to get the name of employee from the sql...
5
by: Crazy Cat | last post by:
Hi all, I have combobox that is bound to a custom object collection thusly Dim collection As List(Of StructureType) = StructureType.FindStructureTypes(SharedObjects.StructureTypes,...
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
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
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: 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...
0
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,...
0
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...

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.