Combobox value property?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Goos van Beek

    #1

    Combobox value property?

    Hello.

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

    private void FillCboRelation (){
    using(SqlComman d sqlStatement = new SqlCommand("sp_ RelationList",c nn)) {
    using(SqlDataRe ader rdReader=sqlSta tement.ExecuteR eader()){
    while(rdReader. Read()){
    cboRelation.Ite ms.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.Ite ms[cboRelation.Ite ms.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.


  • Brian Patterson

    #2
    Re: Combobox value property?

    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:O4e2QdNVDH A.2096@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hello.
    >
    > I'm using the following code to fill a combobox on a Windows form:
    >
    > private void FillCboRelation (){
    > using(SqlComman d sqlStatement = new SqlCommand("sp_ RelationList",c nn)) {
    > using(SqlDataRe ader rdReader=sqlSta tement.ExecuteR eader()){
    > while(rdReader. Read()){
    > cboRelation.Ite ms.Add(rdReader["FullName1"].ToString());
    > }//end while
    > }//end using rdReader
    > }//end using sqlStatement
    > }
    >
    > When using a combobox on a webform I can use for instance
    >
    >[/color]
    cboRelation.Ite ms[cboRelation.Ite ms.Count-1].Value=rdReader["RelationId "].To[color=blue]
    > String();
    >
    > to add some data to the value property of the dropdownlist.
    >
    > Is there a way to do something similar on the combobox?
    >
    > Goos.
    >
    >[/color]


    Comment

    Working...