0

I have loaded combo as following.

cmdString = "select propertytypeid,typename from propertytype ";
             da = new SqlDataAdapter(cmdString, conString);            
             dt_PropertyType = new DataTable();
             da.Fill(dt_PropertyType);          

             cmb_PropertyType.DisplayMember = "Name";
             cmb_PropertyType.ValueMember = "ID";
             arr = new ArrayList();
             for (int i = 0; i < dt_PropertyType.Rows.Count; i++)
             {
                 arr.Add(new KeyValueData(dt_PropertyType.Rows[i][1].ToString(),int.Parse(dt_PropertyType.Rows[i][0].ToString())));             
             }             
             cmb_PropertyType.DataSource = arr;

but How Can I get the hidden id as I change selected item of the combo?

3
Contributors
2
Replies
9
Views
7 Years
Discussion Span
Last Post by __avd
0

Try this one

int value = cmb.SelectedValue;

This will give you the selected value of the selected display member.

0

No need of loop.

da.Fill(dt_PropertyType);          
  cmb_PropertyType.DataSource = dt_PropertyType;
  cmb_PropertyType.DisplayMember = "typename";
  cmb_PropertyType.ValueMember = "propertytypeid";

and use SelectedValue property (see Post #2).

Edited by __avd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.