title: combobox selected value in c#
body: <p>I am working on C#.net windows application. i am filling combobox on my winform by using follows.</p>
  
  <pre><code>cmbEMPType.DataSource = objEntityManager.EmployeeTypes();
  cmbEMPType.DisplayMember = "EMPTypeName";
  cmbEMPType.ValueMember = "EMPTypeId";
  </code></pre>
  
  <p>where <code>objEntityManager.EmployeeTypes();</code> in the manager method that gets the List from Linq to sql server. this is working fine. </p>
  
  <p>but as i select the item form combo box, and clicked the button then in the button click event i am getting <code>cmbEMPType.SelectedValue</code> as <code>EmpType</code> return type rather than its Id. why should this? I don't want to create one more EmpType object. need simple selected value. also can not keep faith with SelectedIndex. it may varies for item each time.</p>
  
  <pre><code>**Edited**
        public List&lt;EMPType&gt; EmployeeTypes()
          {
              List&lt;EMPType&gt; EMPTypeList = null;
              try
              {
                  if (CommonDataObject.dataContext.EMPAllTypes.Any())
                  {
                      EMPTypeList = CommonDataObject.dataContext.EMPAllTypes.ToList();
                  }
                  return EMPTypeList;
              }
              catch
              {
  
                  return EMPTypeList;
              }
  
          }
  </code></pre>
  
  <p><strong>Edited</strong></p>
  
  <pre><code>   private void btnSave_Click(object sender, EventArgs e)
          {
  
  iEMPTypeId = cmbEMPType.SelectedValue;
  }
  </code></pre>
  
  <p>here I must get inte. but asking of create the EMPType object.</p>