title: How to get value from drop down list box
body: <p>What I want is to get the value from the selected item in the drop down list, and use it to query (select table) in a button click event.</p>
  
  <pre><code>    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      {
          if (DropDownList1.SelectedIndex == 1)
          {
              using (SqlConnection con = new SqlConnection(DBcon))
              {
  
                 SqlCommand sqlCommand = new SqlCommand("Select * from tbl_WinApps_FileHeader");
                 sqlCommand.Connection = con;
  
                 SqlDataReader read = sqlCommand.ExecuteReader();
  
                  GridView1.DataSource = read;
                  GridView1.DataBind();
  
  
              }
          }
      }
  
    &lt;asp:DropDownList ID="DropDownList1" runat="server" 
          onselectedindexchanged="DropDownList1_SelectedIndexChanged"&gt;
          &lt;asp:ListItem&gt;ER00 - File Header&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;ER01 - Expense Report Trans&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;ER02 - Expense Report Item Trans&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;ER03 - Expense Report Item Tax Trans&lt;/asp:ListItem&gt;
          &lt;asp:ListItem&gt;ER04 - Expense Report Item&lt;/asp:ListItem&gt;
      &lt;/asp:DropDownList&gt;
  </code></pre>