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

Combobox value property?

P: n/a
Hello.

I'm using the following code to fill a combobox on a Windows form:

private void FillCboRelation(){
using(SqlCommand sqlStatement = new SqlCommand("sp_RelationList",cnn)) {
using(SqlDataReader rdReader=sqlStatement.ExecuteReader()){
while(rdReader.Read()){
cboRelation.Items.Add(rdReader["FullName1"].ToString());
}//end while
}//end using rdReader
}//end using sqlStatement
}

When using a combobox on a webform I can use for instance

cboRelation.Items[cboRelation.Items.Count-1].Value=rdReader["RelationId"].To
String();

to add some data to the value property of the dropdownlist.

Is there a way to do something similar on the combobox?

Goos.
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Add the data to a ListItem object and then add that to the combobox. You
can then assing the SelectItem to a ListItem object and access to chosen
value member.

Brian Patterson

"Goos van Beek" <nvt13ATchello.nl> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
Hello.

I'm using the following code to fill a combobox on a Windows form:

private void FillCboRelation(){
using(SqlCommand sqlStatement = new SqlCommand("sp_RelationList",cnn)) {
using(SqlDataReader rdReader=sqlStatement.ExecuteReader()){
while(rdReader.Read()){
cboRelation.Items.Add(rdReader["FullName1"].ToString());
}//end while
}//end using rdReader
}//end using sqlStatement
}

When using a combobox on a webform I can use for instance

cboRelation.Items[cboRelation.Items.Count-1].Value=rdReader["RelationId"].To String();

to add some data to the value property of the dropdownlist.

Is there a way to do something similar on the combobox?

Goos.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.