OnTextChange event acts weird
<p>I am working on a form having many text box and some drop down list in asp.net,currently I trying to populate these textBox dynamically from the database on the textchange event of a particular textform</p>

<p>i.e the particular textbox named jobId(job id is the primary key of the database table) so if someone enters 10 ,it will populate rest of the field with values with the primary key as 10,</p>

<p>this works for the first time ,but eventually it will give a error like </p>

<pre><code>The state information is invalid for this page and might be corrupted.
</code></pre>

<p>and no values are changed.</p>

<p>Why is this happening ,I tried a lot but just can't get past this error,is it because I am loading an HTML document within another using AJAX?</p>

<p>for further clarification here is my code,</p>

<p>the trigger:</p>

<pre><code>&lt;asp:TextBox ID="Job_No" runat="server" Text="New" 
            ontextchanged="Job_No_TextChanged" AutoPostBack="true"&gt;&lt;/asp:TextBox&gt;
</code></pre>

<p>the function:</p>

<pre><code>  protected void Job_No_TextChanged(object sender, EventArgs e)
    {
        //SqlCommand cmd2 = new SqlCommand("");
        SqlDataAdapter sda = new SqlDataAdapter("select job_no from job_mstr", con);
        DataTable dt = new DataTable();
        sda.Fill(dt);
       // check = 1;
        try
        {
            foreach (DataRow row in dt.Rows)
            {
                if (row["job_no"].ToString() == Job_No.Text)
                {

                   // check = 0;
                    int id = Convert.ToInt32(Job_No.Text);

                    Job_No.Text = id.ToString();
                    con.Open();
                    SqlCommand cmd1 = new SqlCommand("select JOB_MILESTONE_DT,start_dt,end_dt,CUST_REF,convert(varchar,CUST_REF_DT,103) ,convert(varchar,due_date,103) ,JOB_DESC,LINKED_JOB,CLIENT_CONTACT,CONTACT_EMAIL,APPROVAL_USER,convert(varchar,approval_DT,103) ,TOT_QTY,cost,job_type,JOB_CATEGORY from job_mstr where job_no=" + id, con);
                    SqlDataReader dr = cmd1.ExecuteReader();
                    if (dr.Read())
                    {
                        JobM_Dt.Text = dr[0].ToString();
                        StartTim.Text = dr[1].ToString();
                        EndTime.Text = dr[2].ToString();
                        Cust_refTxt.Text = dr[3].ToString();
                        Cust_Ref_DtTxt.Text = dr[4].ToString();
                        Due_DtTxt.Text = dr[5].ToString();
                        Job_DescTxt.Text = dr[6].ToString();
                        Linked_JobTxt.Text = dr[7].ToString();
                        Client_ContactTxt.Text = dr[8].ToString();
                        Client_EmailTxt.Text = dr[9].ToString();
                        Approval_UsrTxt.Text = dr[10].ToString();
                        Approval_DtTxt.Text = dr[11].ToString();
                        Tot_QtyTxt.Text = dr[12].ToString();
                        CostTxt.Text = dr[13].ToString();
                        Job_TypeTxt.Text = dr[14].ToString();
                        Job_CatogeryTxt.Text = dr[15].ToString();


                    }

                    dr.Close();
                    return;
                }
                else if (check == 1)
                {
                    // Job_No.Text = "New";
                    JobM_Dt.Text = "";
                    StartTim.Text = "";
                    EndTime.Text = "";
                    Cust_refTxt.Text = "";
                    Cust_Ref_DtTxt.Text = "";
                    Due_DtTxt.Text = "";
                    Job_DescTxt.Text = "";
                    Linked_JobTxt.Text = "";
                    Client_ContactTxt.Text = "";
                    Client_EmailTxt.Text = "";
                    Approval_UsrTxt.Text = "";
                    Approval_DtTxt.Text = "";
                    Tot_QtyTxt.Text = "";
                    CostTxt.Text = "";
                    Job_TypeTxt.Text = "";
                    Job_CatogeryTxt.Text = "";
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
</code></pre>
