Error: Getting value from controls on a page for button click event
<p>The code below simply gets data from database and populate the data into TextBoxes on asp.net page and when i click a button btnSave any changes on the TextBoxes reflect to the databse.
But when i click the btnSave button the values i'm getting from the Textboxes are the initial ones from Page_Load Event not the ones after i change values on Textboxes</p>

<pre><code>public partial class Settings : System.Web.UI.Page
{
    string conString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;    

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(conString);
        con.Open();
        SqlCommand cmd = new SqlCommand("SELECT CompanyAUserName, CompanyAPassword, CompanyAEmail, CompanyBUserName, CompanyBPassword, AgentAName, AgentBName, ItemShortageNotification FROM COMPANY_SETTINGS", con);
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            txtHostName.Text =  dr["CompanyAUserName"].ToString();
            txtHostPassword.Text = dr["CompanyAPassword"].ToString();
            txtHostEmail.Text = dr["CompanyAEmail"].ToString();
            txtClientName.Text = dr["CompanyBUserName"].ToString();
            txtClientPassword.Text = dr["CompanyBPassword"].ToString();
            txtAgentAName.Text = dr["AgentAName"].ToString();
            txtAgentBName.Text = dr["AgentBName"].ToString();
            txtItemQty.Text = dr["ItemShortageNotification"].ToString();            
        }
        con.Close();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {        
        SqlConnection con = new SqlConnection(conString);
        con.Open();                
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;        
        try
        {
            cmd.CommandText =
            "UPDATE COMPANY_SETTINGS SET CompanyAUserName = @CompanyAUserName, CompanyAPassword = @CompanyAPassword, CompanyAEmail = @CompanyAEmail, CompanyBUserName = @CompanyBUserName, CompanyBPassword = @CompanyBPassword, AgentAName = @AgentAName, AgentBName = @AgentBName, ItemShortageNotification = @ItemShortageNotification";
            cmd.Parameters.AddWithValue("@CompanyAUserName", txtHostName.Text);
            cmd.Parameters.AddWithValue("@CompanyAPassword", txtHostPassword.Text);
            cmd.Parameters.AddWithValue("@CompanyAEmail", txtHostEmail.Text);
            cmd.Parameters.AddWithValue("@CompanyBUserName", txtClientName.Text);
            cmd.Parameters.AddWithValue("@CompanyBPassword", txtClientPassword.Text);
            cmd.Parameters.AddWithValue("@AgentAName", txtAgentAName.Text);
            cmd.Parameters.AddWithValue("@AgentBName", txtAgentBName.Text);
            cmd.Parameters.AddWithValue("@ItemShortageNotification", txtItemQty.Text.Trim());
            cmd.ExecuteNonQuery();
            Response.Redirect("~/Settings.aspx");
        }
        catch (Exception ex)
        {
            Response.Write("&lt;script&gt;alert('Error: " + ex.Message + "')&lt;/script&gt;");            
        }        
        con.Close();        
    }
}
</code></pre>

<p>Here is a part of code from .aspx page</p>

<pre><code>&lt;asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderBody" Runat="Server"&gt;
    &lt;div style="height:100%;" runat="server" id="divSettings"&gt;        
        &lt;h3 style="padding:0; margin:0"&gt;Settings&lt;/h3&gt;
        &lt;h5 style="padding: 5px"&gt;(This page is only visible to the host)&lt;/h5&gt;
        &lt;table class="SignUpTable" runat="server"&gt;
            &lt;tr runat="server"&gt;
                &lt;td align="center" colspan="2" runat="server"&gt;
                    &lt;h1&gt;Company A Information&lt;/h1&gt;
                    &lt;p&gt;This is host account infromation. &lt;/p&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr runat="server"&gt;
                &lt;td class="label" runat="server" &gt;
                    &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserNameLabel"&gt;User Name: &lt;/asp:Label&gt;&lt;br /&gt;
                    &lt;div class="small"&gt; Minimun of 4 characters &lt;/div&gt;
                &lt;/td&gt;
                &lt;td runat="server"&gt;
                    &lt;asp:TextBox ID="txtHostName" runat="server" CssClass="textBox"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;
                    &lt;asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                        ControlToValidate="txtHostName" Text="Host name is required." 
                        ToolTip="Enter Host Name" Display="Dynamic" 
                        ValidationGroup="ValidationSettings" SetFocusOnError="True"/&gt;
                    &lt;asp:RegularExpressionValidator ID="RegularExpressionValidator1" SetFocusOnError="True"
                            runat="server" ControlToValidate="txtHostName" Display="Dynamic" 
                        ValidationExpression="[0-9a-zA-Z]{4,}" ValidationGroup="ValidationSettings"&gt;Host name must be more than 4 characters.&lt;/asp:RegularExpressionValidator&gt;
                &lt;/td&gt;
            &lt;/tr&gt; 
</code></pre>

<p>I tried to use FindControl() and still getting the same value.
Please tell me know what i am missing. Thank you.</p>
