title: Dropdown values being reset to initial value upon submit
body: <p>I have used the following code to insert the selected item from dropdownlist into the sql database table. It runs, but the selected item for dropdownlist 1, 2, 5 and 6 always stores the first item in the dropdown list.
  Here's my code</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
  {
      if(!IsPostBack)
      {
          //populate gridview
          TextBox2.Focus();
          string selectquery = "select [TASK ID],[NATURE OF PAYMENT],[DESC],FREQUENCY,PREALERT1,PREALERT2,OWNER,[VERIFICATION OWNER],(case when STATUS='1' then 'Active' when STATUS='0' then 'Inactive' ELSE 'UNKNOWN' END)as STATUS,ID from Compliance_Tracker.dbo.tasklistManager;";
          obj6.PopulateGrid(GridView1, selectquery);
      }
      {
          // populate dropdownlist for prealert 1
          for (int i = 0; i &lt;= 30; i++)
          {
              DropDownList3.Items.Insert(i, new ListItem((i + 1).ToString(), (i + 1).ToString()));
          }
          DropDownList3.DataBind();
      }
      {
          // populate dropdown list for prealert 2
          for (int j = 0; j &lt;= 30; j++)
          {
              DropDownList4.Items.Insert(j, new ListItem((j + 1).ToString(), (j + 1).ToString()));
          }
          DropDownList4.DataBind();
      }
      {
          //populate dropdown for Nature of Payment
          string query = "select * from Compliance_Tracker.dbo.paymentNatureMaster where STATUS='1';";
          string columnname = "DESC";
          string datavaluefield="DESC";
          obj6.PopulateCombo(DropDownList1,query,columnname,datavaluefield);
      }
      {
          //populate dropdown for frequency
          string query1 = "select * from Compliance_Tracker.dbo.frequencyMaster where STATUS='1';";
          string columnname1 = "DESC";
          string datavaluefield1 = "DESC";
          obj6.PopulateCombo(DropDownList2,query1, columnname1,datavaluefield1);
      }
      {
          //populate dropdown for owner
          string query2 = "select * from Compliance_Tracker.dbo.ownerMaster where STATUS='1';";
          string columnname2 = "NAME";
          string datavaluefield2 = "NAME";
          obj6.PopulateCombo( DropDownList5,query2, columnname2,datavaluefield2);
      }
      {
          //populate dropdown for owner verification
          string query3 = "select * from Compliance_Tracker.dbo.verificationMaster where STATUS='1'";
          string columnname3 = "NAME";
          string datavaluefield3 = "NAME";
          obj6.PopulateCombo(DropDownList6,query3, columnname3,datavaluefield3);
      }
  </code></pre>
  
  <p>mybutton click event sorry i forgot to add the main thing</p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
  {
      string query = "insert into Compliance_Tracker.dbo.tasklistManager([NATURE OF PAYMENT],[DESC],FREQUENCY,PREALERT1,PREALERT2,OWNER,[VERIFICATION OWNER],STATUS)values('" + DropDownList1.SelectedValue.ToString() + "','" + TextBox2.Text + "','" + DropDownList2.SelectedItem.Text + "','" + DropDownList3.SelectedItem.Text + "','" + DropDownList4.SelectedItem.Text + "','" + DropDownList5.SelectedItem.Text + "','" + DropDownList6.SelectedItem.Text + "','" + DropDownList7.SelectedValue + "');";
      obj6.ExecuteScalar(query);
      string selectquery = "select [TASK ID],[NATURE OF PAYMENT],[DESC],FREQUENCY,PREALERT1,PREALERT2,OWNER,[VERIFICATION OWNER],(case when STATUS='1' then 'Active' when STATUS='0' then 'Inactive' ELSE 'UNKNOWN' END)as STATUS,ID from Compliance_Tracker.dbo.tasklistManager;";
      obj6.PopulateGrid(GridView1, selectquery);
      TextBox2.Text = string.Empty;
      DropDownList7.SelectedItem.Text = "Active";
  }
  protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { }
  protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { }
  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { }
  protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { }
  protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { }
  </code></pre>
  
  <p>}</p>
  
  <p>this is my html code</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/LoggedInMasterPage.master" AutoEventWireup="true" CodeFile="TaskList.aspx.cs" Inherits="TaskList" %&gt;
  </code></pre>
  
  
  
  <p>
      
          
           <h1>
          TASKLIST MANAGER TABLE
      </h1>
           
              
                   
                   
                   
              
              
                   
                   
                       
                      <br /> 
                   
              
              
                   
                   
                   
              
              
                   
                    
                       <br>
                   
              
              
                   
                   
                   
              
              
                   
                   
                   
              
              
                   
                   
                   
              
              
                 
                  
                      
                      
                 
                 
              
         <br />
         
         
              
             </p>
  
  <pre><code>       &lt;asp:TemplateField HeaderText="TASK ID" SortExpression="TASK ID" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
             &lt;ItemTemplate&gt;
                 &lt;asp:Label ID="TASKID" runat="server" Text='&lt;%#Eval("[TASK ID]") %&gt;' /&gt;
             &lt;/ItemTemplate&gt;
         &lt;/asp:TemplateField&gt;
  
         &lt;asp:TemplateField HeaderText="NATURE OF PAYMENT" SortExpression="NATURE OF PAYMENT" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
             &lt;ItemTemplate&gt;
                 &lt;asp:Label ID="NOP" runat="server" Text='&lt;%#Eval("[NATURE OF PAYMENT]") %&gt;' /&gt;
             &lt;/ItemTemplate&gt;
             &lt;EditItemTemplate&gt;
                 &lt;asp:DropDownList runat="server" ID="dropdownnop"&gt;&lt;/asp:DropDownList&gt;
             &lt;/EditItemTemplate&gt;
         &lt;/asp:TemplateField&gt;
  
  
          &lt;asp:TemplateField HeaderText="DESC" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
            &lt;ItemTemplate&gt;
            &lt;asp:Label runat="server" ID="DESC" Text='&lt;%#Eval("[DESC]") %&gt;'/&gt;
            &lt;/ItemTemplate&gt;
            &lt;EditItemTemplate&gt;
           &lt;asp:TextBox ID ="DESC" runat="server" Text='&lt;%#Eval("[DESC]") %&gt;'&gt;&lt;/asp:TextBox&gt;
           &lt;asp:RequiredFieldValidator ID="REQUIREDFIELDVALIDATORDESC" runat="server" ControlToValidate="DESC" ErrorMessage="FIELD CANNOT BE EMPTY"&gt;&lt;/asp:RequiredFieldValidator&gt;
            &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="FREQUENCY" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="FREQUENCY" Text='&lt;%#Eval("FREQUENCY") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList runat="server" ID="dropdownfreq"&gt;&lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="DUE DATE OF PAYMENT" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="DDOP" Text='&lt;%#Eval("PREALERT1") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList runat="server" ID="dropdownddop"&gt;&lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="DUE DATE OF SUBMISSION OF RETURN" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="DDOSOR" Text='&lt;%#Eval("PREALERT2") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList runat="server" ID="dropdownddosor"&gt;&lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="OWNER" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="OWNER" Text='&lt;%#Eval("OWNER") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList runat="server" ID="dropdownowner"&gt;&lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="VERIFICATION OWNER" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label runat="server" ID="VO" Text='&lt;%#Eval("[VERIFICATION OWNER]") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:DropDownList runat="server" ID="dropdownvo"&gt;&lt;/asp:DropDownList&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="STATUS" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
            &lt;ItemTemplate&gt;
            &lt;asp:Label runat="server" ID="STATUS" Text='&lt;%#Eval("STATUS") %&gt;'/&gt;
            &lt;/ItemTemplate&gt;
            &lt;EditItemTemplate&gt;
            &lt;asp:DropDownList runat ="server" ID="dropdownstatus"&gt;
                &lt;asp:ListItem Text="Active" Value="1"&gt;&lt;/asp:ListItem&gt;
                &lt;asp:ListItem Text="Inactive" Value="0"&gt;&lt;/asp:ListItem&gt;
                &lt;/asp:DropDownList&gt;
            &lt;/EditItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField Visible="false" HeaderText="ID"&gt;
              &lt;ItemTemplate&gt;
              &lt;asp:Label runat="server" ID="ID" Text='&lt;%#Eval("ID") %&gt;' /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
           &lt;asp:TemplateField HeaderText="Action" HeaderStyle-BackColor="DarkGreen" HeaderStyle-ForeColor="White"&gt;
           &lt;ItemTemplate&gt;
           &lt;asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" /&gt;
           &lt;asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete" /&gt;
           &lt;/ItemTemplate&gt;
           &lt;EditItemTemplate&gt;
           &lt;asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" /&gt;
           &lt;asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" /&gt;
           &lt;/EditItemTemplate&gt; 
           &lt;/asp:TemplateField&gt;
         &lt;/Columns&gt;
          &lt;PagerSettings FirstPageText="First" LastPageText="Last" Mode="NumericFirstLast" PageButtonCount="4" /&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>and here's my populatecombo code</p>
  
  <pre><code> public bool PopulateCombo(DropDownList DDList, string strSQL, string DisMember, string ValMember)
      {
          SqlDataAdapter DAdpt = new SqlDataAdapter();
          DataSet DSet = new DataSet();
          try
          {
              if (Conn.State == ConnectionState.Closed)
                  Conn.Open();
              DAdpt = new SqlDataAdapter(strSQL, Conn);
              DAdpt.Fill(DSet);
              DDList.DataSource = DSet.Tables[0];
              DDList.DataTextField = DisMember;
              DDList.DataValueField = ValMember;
              DDList.DataBind();
              return true;
          }
          catch (Exception Ex)
          {
              //return null;
              throw new Exception(Ex.Message);
          }
          finally
          {
              DAdpt.Dispose();
              DSet.Dispose();
              Conn.Close();
          }
      }
  </code></pre>
  
  <p>here is my executescalar function</p>
  
  <pre><code> public object ExecuteScalar(string strSQL)
      {
          try
          {
              if (Conn.State == ConnectionState.Closed)
                  Conn.Open();
              Comm = new SqlCommand(strSQL, Conn);
              return Comm.ExecuteScalar();
          }
          catch (Exception Ex)
          {
              //return null;
              throw new Exception(Ex.Message);
          }
          finally
          {
              Comm.Dispose();
              Conn.Close();
          }
      }
  </code></pre>