0
我有很多文本框和一些下拉在asp.net列表中的窗體上工作,目前我試圖從特定textform的textchange事件數據庫動態填充這些textBox中OnTextChange事件行爲怪異
即名爲jobId的特定文本框(作業ID是數據庫表的主鍵),因此如果有人輸入10,它將填充字段的其餘部分,其中主鍵爲10,
這是第一次工作,但最終還是會給像
The state information is invalid for this page and might be corrupted.
一個錯誤
,沒有值的變化。
爲什麼會這樣,我想了很多,但就是不能把過去的這個錯誤,是不是因爲我加載另一個使用AJAX中的HTML文檔?
這裏進一步的澄清是我的代碼,
觸發:
<asp:TextBox ID="Job_No" runat="server" Text="New"
ontextchanged="Job_No_TextChanged" AutoPostBack="true"></asp:TextBox>
功能:
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);
}
}
你有在Page_Load中的任何代碼? – adatapost 2012-07-05 09:05:16