title: ASP.Net dropdown always return first value on button click event
body: <p>I am trying to save value from a simple asp.net form.</p>
  
  <p>I have few controls on the page like drop-down &amp; text-box's</p>
  
  <p>I fill the first drop-down on page load with Language &amp; trigger post-bask on same to fill the second drop-down <code>ddCategoryType</code> which it fills with correct values based on the language selected, but problem is when i try to get the value on button click event value for ddCategoryType.SelectedItem.Value always return 0 for some reason which i am not able figure out right now</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          ddSelectLanguage.Items.Clear();
          ddSelectLanguage.DataSource = DataProvider.GetLanguages();
          ddSelectLanguage.DataBind();
          ddSelectLanguage.Items.Insert(0, new ListItem("Select Language", "0"));
      }
      else
      {
          ddCategoryType.Items.Clear();
          String strSql = "SELECT TypeName, TypeID FROM  CategoryType WHERE LangID =" + ddSelectLanguage.SelectedItem.Value.ToString();
          DataSet ds = new DataSet();
          ds = DataProvider.Connect_Select(strSql);
          ddCategoryType.DataSource = ds;
          ddCategoryType.DataBind();
          ddCategoryType.Items.Insert(0, new ListItem("Select Type", "0"));
      }
  }
  
  
  protected void btnSaveCategory_Click(object sender, EventArgs e)
  {
      objArtCat.LanguageID = int.Parse(ddSelectLanguage.SelectedItem.Value.ToString());
      objArtCat.CategoryName = txtCategoryName.Text;
      objArtCat.CategoryType = int.Parse(ddCategoryType.SelectedItem.Value.ToString());
      objArtCat.CategoryActive = bool.Parse(ddCategoryActive.SelectedItem.Value.ToString());
      try
      {
          //bool result;
          //result = objBLAddArticleCategory.CreateNewArticleCategory(objArtCat);
          //if (result == true)
          //{
          //    Response.Redirect("PageMessage.aspx?msg='Category has been Create Successfully'", true);
          //}
          //else
          //{
          //}
      }
      catch (Exception)
      { }
  }
  </code></pre>
  
  <p>SAMPLE .ASPX CODE</p>
  
  <pre><code>   &lt;div  class="row"&gt;&lt;/div&gt;
                &lt;div class="row"&gt;
              &lt;asp:Label ID="lblSelectLang" CssClass="txtLabel"  Text="Select Language  :" runat="server" &gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="ddSelectLanguage" runat="server" CssClass="ddGeneral" 
                        DataTextField="LangName" DataValueField="LangID" CausesValidation="True" 
                        AutoPostBack="True"  &gt;
              &lt;/asp:DropDownList&gt;
           &lt;asp:RequiredFieldValidator ID="rfvddLanguage" runat="server" ErrorMessage="Please Select Language"  ControlToValidate="ddSelectLanguage" 
           InitialValue="Select Language" ValidationGroup="atpAddNewArticle" &gt;&lt;/asp:RequiredFieldValidator&gt;
         &lt;/div&gt;
  
         &lt;div class="row"&gt;
              &lt;asp:Label ID="lblCategoryName" CssClass="txtLabel" runat="server" Text="Category Name :"&gt;&lt;/asp:Label&gt;
              &lt;asp:TextBox ID="txtCategoryName" runat="server" CssClass="txtbox300"&gt;&lt;/asp:TextBox&gt;
              &lt;asp:RequiredFieldValidator ID="RFVtxtAuthorName" runat="server" ErrorMessage="*" 
                  ControlToValidate="txtCategoryName" ValidationGroup="atpAddNewArticle"  CssClass="validation"&gt;&lt;/asp:RequiredFieldValidator&gt;
         &lt;/div&gt;
  
         &lt;div class="row"&gt;
              &lt;asp:Label ID="lblCategoryType" CssClass="txtLabel" runat="server" Text="Category Type :"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="ddCategoryType" runat="server" CssClass="ddGeneral"   DataTextField="TypeName" DataValueField="TypeID" &gt;
              &lt;/asp:DropDownList&gt;
         &lt;/div&gt;
  
         &lt;div class="row"&gt;
              &lt;asp:Label ID="lblCategoryActive" CssClass="txtLabel" runat="server" Text="Category Active :"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="ddCategoryActive" runat="server" CssClass="ddGeneral"  &gt;
                  &lt;asp:ListItem Value="False" Selected="True"&gt;NO&lt;/asp:ListItem&gt;
                  &lt;asp:ListItem Value="True"&gt;YES&lt;/asp:ListItem&gt;
              &lt;/asp:DropDownList&gt;
         &lt;/div&gt;
  
         &lt;div class="rowButton"&gt;
              &lt;/br&gt;
              &lt;asp:Button ID="btnUpdateArticle" runat="server" Text="Save Category" CssClass="btn"  ValidationGroup="atpAddNewArticle" onclick="btnSaveCategory_Click" /&gt;                &lt;input id="Reset" type="reset" class="btn" value="Reset" /&gt;
         &lt;/div&gt;
  </code></pre>
  
  <p>OutPut for ddCategoryType after postback</p>
  
  <pre><code>&lt;div class="row"&gt;
                  &lt;span class="txtLabel" id="MainContent_lblCategoryType"&gt;Category Type :&lt;/span&gt;
                  &lt;select class="ddGeneral" id="MainContent_ddCategoryType" name="ctl00$MainContent$ddCategoryType"&gt;
      &lt;option value="0" selected="selected"&gt;Select Type&lt;/option&gt;
      &lt;option value="1"&gt;Article&lt;/option&gt;
      &lt;option value="2"&gt;News&lt;/option&gt;
      &lt;option value="3"&gt;Sports&lt;/option&gt;
      &lt;option value="4"&gt;People&lt;/option&gt;
      &lt;option value="5"&gt;Message&lt;/option&gt;
  
  &lt;/select&gt;
             &lt;/div&gt;
  </code></pre>