title: ASP.NET and C# - Get selected item in static DropDownList
body: <p>I'm new to ASP.NET and I'm having problem with getting selected item in static DropDownList. This is the structure of my list:</p>
  
  <pre><code>                   &lt;asp:DropDownList ID="txtGender" runat="server"&gt;
                              &lt;asp:ListItem&gt;Male&lt;/asp:ListItem&gt;
  
                              &lt;asp:ListItem&gt;Female&lt;/asp:ListItem&gt;
  
                              &lt;asp:ListItem&gt;Other&lt;/asp:ListItem&gt;
  
                              &lt;asp:ListItem&gt;Rather not say&lt;/asp:ListItem&gt;
                      &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>Then in the code where I want to get the selected item, I use <code>txtGender.SelectedItem</code> and always get the first item as input. I have another DropDownList where I have to fetch the items from database, then I use <code>IsPostBack</code> before calling <code>DataBind()</code> and it works fine. So I'm wondering how should I use <code>IsPostBack</code> in static DropDownList as above? Please help.</p>
  
  <p>*<em>EDITED</em></p>
  
  <p>Below is the method that I use the <code>txtGender</code>:</p>
  
  <pre><code>protected void btnSave_Click(object sender, EventArgs e)
  {
      int uID= int.Parse(Session["uID"].ToString());
      PhotoDataSetTableAdapters.MembersTableAdapter memAdap = new PhotoDataSetTableAdapters.MembersTableAdapter();
      PhotoDataSet.MembersDataTable memTable = memAdap.GetMemberByID(uID);
  
      DataRow[] dr = memTable.Select("userID = " + uID);
      string Fname = memTable.AsEnumerable().Single().Field&lt;String&gt;("avatar");
      if(PhotoUploader.HasFile)
      {
         Fname = Path.GetFileName(PhotoUploader.FileName);
         PhotoUploader.SaveAs(Server.MapPath("~/avatar/") + Fname);
      }
  
      string newPass = memTable.AsEnumerable().Single().Field&lt;String&gt;("password");
      if (txtPass.Text != "")
      {
          newPass = txtPass.Text;
      }
  
      string tmp = txtBday.Text;
      DateTime bday = DateTime.ParseExact(tmp, "dd/MM/yyyy", null);
  
      memAdap.UpdateMemberProfile(newPass, txtEmail.Text, txtRealname.Text, txtLocation.Text, txtGender.SelectedItem.Text, txtBio.Text, bday, Fname, uID);
      //Response.Write(txtGender.SelectedItem.Text + " " + txtBio.Text);
      Response.Redirect("Photostream.aspx");
  }
  </code></pre>
  
  <p>P.s: I tried using <code>Response.Write</code> to see the input for gender but it's always the first item of the list to be selected. I also have no input for <code>txtBio</code> even though everything seems alright. </p>