我问的原因是因为我有一个更新面板,里面装满了文本框、标签等,我根据用户点击的内容使其可见/不可见。后来,我运行一个循环来清除所有的文本框。它以前工作得很好,但现在我添加了 AJAX 更新面板,它给了我一个“无效的回发或回调参数”错误。
这是因为那个 AJAX 更新面板吗?还是我自己做错了什么?
谢谢,艾莉
[编辑]:好的,我正在添加一大堆代码,因为我不知道它来自哪里:
这是写入记录的方法:
protected void AddEmployerRecord()
{
connection = new SqlConnection();
connection.ConnectionString = "****";
connection.Open();
newEmployer = new EmployerCRUD(connection);
employerRow.employerName = tb_employer.Text;
employerRow.empPhone = tb_phone.Text;
employerRow.empFax = tb_fax.Text;
employerRow.empEmail = tb_email.Text;
employerRow.empAddress = tb_address.Text;
employerRow.empCity = tb_city.Text;
employerRow.empState = ddl_state.SelectedValue.ToString();
employerRow.empZIP = tb_ZIP.Text;
employerRow.startDate = Convert.ToDateTime(tb_fromDate.Text);
employerRow.endDate = Convert.ToDateTime(tb_toDate.Text);
employerRow.startPay = Convert.ToDecimal(tb_startPay.Text);
employerRow.endPay = Convert.ToDecimal(tb_endPay.Text);
employerRow.leaveReason = tb_leaveReason.Text;
employerRow.supervisorFName = tb_superFName.Text;
employerRow.supervisorLName = tb_superLName.Text;
employerRow.contactForRef = rbl_contact.SelectedValue.ToString();
employerRow.jobDesc = tb_jobDesc.Text;
employerRow.applicantID = 10010;
//employerRow.applicantID = Convert.ToInt32(Session["ApplicantNum"]);
employerRow.supervisorTitle = tb_superTitle.Text;
employerRow.jobTitle = tb_jobTitle.Text;
employerRow.startPayType = ddl_startPayType.SelectedValue.ToString();
employerRow.endPayType = ddl_endPayType.SelectedValue.ToString();
ct_emp = newEmployer.Add(employerRow);
// *************** Error Message *************** //
//if (ct_emp.Message != "OK")
// Error message
//else
//
connection.Close();
}
这是加载网格的方法:
protected void LoadGrid()
{
try
{
SqlConnection pConnection = new SqlConnection();
pConnection.ConnectionString = "**";
pConnection.Open();
string sqlstatement = "SELECT EmployerID, EmployerName FROM dbo.EMPLOYER WHERE ApplicantID = @applicantID";
command = new SqlCommand(sqlstatement, pConnection);
command.Parameters.AddWithValue("@applicantID", 10010);
//command.Parameters.AddWithValue("@applicantID", Session["ApplicantNum"].ToString().Trim());
ds = new DataSet();
adapter = new SqlDataAdapter(command);
builder = new SqlCommandBuilder(adapter);
adapter.Fill(ds);
gv_employers.DataSource = ds.Tables[0];
gv_employers.DataBind();
pConnection.Close();
}
catch (Exception error)
{
Response.Write(error.Message);
}
}
顺便说一句,当我调试东西(需要一致性)时,申请人 ID 只有 10010。
另外,我在某处读到,当您尝试将数据重新绑定到网格时会出现此问题。每次重新加载页面时,我都会运行该 LoadGrid() 方法。我应该将数据绑定到其他地方吗?如果是这样,怎么做?