title: How do I bind the textbox to a dropdownlist?
body: <p>I have a dropdownlist that allows user to select the <code>SupplierName</code>. It worked.
  The problem is that I need the textbox to be filled with corresponding <code>SupplierEmail</code>:</p>
  
  <pre><code>protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
  {
      //  FetchData();
      DataTable dt = new DataTable();
      con.Open();
  
      SqlCommand cmd1 = new SqlCommand("ePMT_SP_BindSupplierDDLToTextBox", con);
      cmd1.Parameters.Add(new SqlParameter("@SupplierEmail",ddlSupplier.SelectedItem));            
      // txtSupplierEmail.Text = dt.Rows[0]["SupplierEmail"].ToString(); 
      // SqlDataReader datareader = cmd.ExecuteReader();                
      foreach (DataRow row in dt.Rows)
      {
          txtSupplierEmail.Text = row["SupplierEmail"].ToString();
      }
  }
  </code></pre>
  
  <p>The stored procedure for <code>ePMT_SP_BindSupplierDDLToTextBox</code>:</p>
  
  <pre><code>SELECT SupplierEmail 
  FROM dbo.EPMT_MASTER_SUPPLIER 
  WHERE SupplierName = @SupplierName
  </code></pre>
  
  <p>The stored procedure for <code>ePMT_SP_BindSupplier</code>:</p>
  
  <pre><code>SELECT SupplierName 
  FROM SSMC_EPMT.dbo.EPMT_MASTER_SUPPLIER 
  
  private void BindDropdownlist()
  {
      DataTable dtSupplier = eBiz.BindSupplier();
      ddlSupplier.DataSource = dtSupplier;
      ddlSupplier.DataTextField = "SupplierName";
      ddlSupplier.DataValueField = "SupplierName";
      ddlSupplier.DataBind();
      ddlSupplier.Items.Insert(0, new ListItem("--Select--", "0"));
  }
  
  &lt;label class="col-md-4 control-label" for="inputRefNo"&gt;
       Vendor :&lt;span style="color: red"&gt;*&lt;/span&gt;
  &lt;/label&gt;
  &lt;div class="input-group col-md-8"&gt;
      &lt;asp:DropDownList ID="ddlSupplier" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" runat="server" CssClass="form-control" AutoPostBack="true"&gt;&lt;/asp:DropDownList&gt;
  &lt;/div&gt;
  </code></pre>