Combobox value property?

  • Thread starter Thread starter Goos van Beek
  • Start date Start date
G

Goos van Beek

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.
 
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
 
Back
Top