title: How to get asp Dropdownlist selected value in c# file?
body: <p>I have a follow dropdown list in my <code>aspx</code> page:</p>
  
  <pre><code> &lt;asp:DropDownList ID="OrderPeriodStatus" runat="server" AutoPostBack="true"
      CssClass="ddlb" Width="100px" Height="30px" DataSourceID="SqlDataSource5" 
      DataTextField="OrderPeriod" DataValueField="OrderPeriodID" onselectedindexchanged="OrderPeriodStatus_SelectedIndexChanged"&gt;
       &lt;/asp:DropDownList&gt;
  
  &lt;asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="&lt;%$ ConnectionStrings:ProdDB %&gt; # blah blah query
      &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>I tried to access the value of selected value in C# by following code:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
  
          if (!IsPostBack)
          {
              ProcessEligibleScenarios();
              LoadOptions();
              ddlbPeriod.DataBind();
              GridView1.DataBind();
              gvActiveLogs.DataBind();
          }
      }
  
  protected void OrderPeriodStatus_SelectedIndexChanged(object sender, EventArgs e)
      {
          if (OrderPeriodStatus.SelectedValue != null)
          {
              SqlConnection myConn = default(SqlConnection);
              SqlCommand myComm = default(SqlCommand);
              myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProdDB"].ConnectionString);
              myConn.Open();
              myComm = new SqlCommand("SELECT OrderPeriodDate, OrderPeriodStatus, Notes FROM OrderPeriod WHERE OrderPeriod ='" + OrderPeriodStatus.SelectedValue + "'");
              try
              {
                  myComm.Connection = myConn;
                  SqlDataReader Dr = myComm.ExecuteReader();
                  while (Dr.Read())
                  {
                      System.Diagnostics.Debug.Write("While reading the data");
                      TextBox1.Text = Dr["OrderPeriodDate"].ToString();
                      TextBox2.Text = Dr["OrderPeriodStatus"].ToString();
                      NotesArea.Value = (string)Dr["Notes"];
                      System.Diagnostics.Debug.WriteLine(OrderPeriodStatus.SelectedValue);
                  }
                  Dr.Close();
                  myConn.Close();
              }
              catch (SqlException sqx)
              {
              }
              GridView1.DataBind();
          }
          else {  }
      }
  </code></pre>
  
  <p>But when i print the <code>value</code>. It shows the selected Index not the value. Why?</p>