【发布时间】:2020-12-16 15:05:59
【问题描述】:
我想向用户显示一条消息,如下所示:Duplicate Value Not Allowed。
为此,我使用jQuery。第一次按预期工作,但不幸的是,每次都显示一次性消息 - 它显示相同的文本。如何预防?
.JS
function OnEndCallback() {
if (gvc.cpInsertNote == undefined || gvc.IsNewItemEditing() || gvc.IsEditing() ) {
// Egnore || gvc.IsNewItemEditing ||gvc.IsEditing
}
else {
if (gvc.cpInsertNote != "") {
alert(gvc.cpInsertNote);
}
}
// return false;
}
我在网格视图更新点击时调用这个函数
网格:
<Templates>
<DetailRow>
<dx:ASPxGridView ID="dgCustomers" runat="server" KeyFieldName="CustomerLineItemID" OnBeforePerformDataSelect="dgCustomers_BeforePerformDataSelect"
OnDataBinding="dgCustomers_DataBinding" ClientInstanceName="gvc"
Width="100%" OnRowDeleting="dgCustomers_RowDeleting" OnRowInserting="dgCustomers_RowInserting"
OnRowUpdating="dgCustomers_RowUpdating" CellStyle-HorizontalAlign="Center">
<ClientSideEvents EndCallback="OnEndCallback" />
<Columns>
...
.CS
int CustomerCount = 0;
SqlCommand cmddupCust = new SqlCommand("select count(*) from GA_LineItemsCustomers where CustomerCode = @CustomerCode and LineItemID=@LineItemID", con);
cmddupCust.Connection = con;
cmddupCust.CommandType = System.Data.CommandType.Text;
cmddupCust.Parameters.AddWithValue("@CustomerCode", CustomerCode);
cmddupCust.Parameters.AddWithValue("@LineItemID", LineItemID);
con.Open();
CustomerCount = Convert.ToInt32(cmddupCust.ExecuteScalar());
con.Close();
if (CustomerCount > 0)
{
((ASPxGridView)sender).JSProperties["cpInsertNote"] = "Duplicate Entries Not Allowed";
e.Cancel = true;
return;
}
【问题讨论】:
-
在英语中,大多数单词没有大写字母,句子以句号结尾。问题以问号结尾,短语以逗号结尾。段落也是允许的。我为你修好了。请尽量写清楚,而不是一堆乱七八糟的字。这会让其他人更容易帮助你。我知道英语可能不是你的第一语言,但我认为同样的规则也适用于大多数其他语言。
-
感谢您的帮助
标签: c# jquery asp.net aspxgridview