你能告诉我为什么当我使用以下代码更新我的详细信息视图时什么都没有发生吗
protected void newOrderDetailsView_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
TextBox txtNote = (TextBox)newOrderDetailsView.FindControl("txtNote");
TextBox txtOrderDate = (TextBox)newOrderDetailsView.FindControl("txtOrderDate");
TextBox txtDueDate = (TextBox)newOrderDetailsView.FindControl("txtDueDate");
TextBox txtCustPO = (TextBox)newOrderDetailsView.FindControl("txtCustPO");
TextBox txtContact = (TextBox)newOrderDetailsView.FindControl("txtContact");
string Query = "Update Orders Set note='" + txtNote.Text + "' ,orderDate =CAST('" + txtDueDate + "'AS DATETIME) ,dueDate = CAST('" + txtDueDate + "'AS DATETIME) ,customerPurchaseOrder='" + txtCustPO.Text + "',contact='" + txtContact.Text + "' where orderId =" + ParentOrder;
ExecuteQuery(Query);
StatusLbl.Text = "Order Updated";
}
private void ExecuteQuery(string Query)
{
try
{
SqlConnection con = DataAccess.Connection.GetDBConnection();
SqlCommand cmd = new SqlCommand(Query, con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception) { }
}
当我按下更新按钮时,我实际放入事件处理程序中的消息正在显示,但没有发生更新
编辑:所以我尝试直接输入值并且它起作用并且更新成功,......我在这里错过了什么???请帮忙