我在 asp updatePanel 中有一个 DevExpress gridView。
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="upWWWGrid" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<dx:ASPxGridView ID="grdWWW" runat="server" KeyFieldName="WWWID" AutoGenerateColumns="false" Visible="false" OnRowInserting="grdWWW_RowInserting" OnRowInserted="grdWWW_RowInserted">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0" Caption=" ">
<ClearFilterButton Visible="True" />
<NewButton Visible="true" />
<EditButton Visible="true" />
<DeleteButton Visible="true" />
</dx:GridViewCommandColumn>
<dx:GridViewDataColumn FieldName="WWWID" VisibleIndex="1" Caption="WWW ID">
<EditFormSettings Visible="False" />
</dx:GridViewDataColumn>
<SettingsEditing Mode="EditFormAndDisplayRow" EditFormColumnCount="2" />
<SettingsPager PageSize="20" AlwaysShowPager="true" />
<SettingsBehavior AllowSort="true" ConfirmDelete="true" />
<Settings ShowFilterRow="true" ShowTitlePanel="true" />
</Columns>
</dx:ASPxGridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
我想通过执行以下操作在 onRowInserted() 事件中触发 javascript 警报 以下:
string Message = "Hello World!";
ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", String.Format("alert('{0}');", Message), true);
但似乎从未注册过警报。我认为问题与 gridView 使用回调执行所有操作这一事实有关。知道如何在创建新记录后触发此警报吗?我遇到的大多数示例都演示了如何使用客户端 SelectionChanged 事件和 onCustomCallback 来执行此操作。
最佳答案
你可以试试这样的:
protected void Grid_RowInsertedEvent(object sender, ASPxDataInsertedEventArgs e)
{
JSProperties["cp_RowInserted"] = true;
...
}
// I prefer this in grid's Init event handler but you can place it in
// RowInserted as well
ClientSideEvents.EndCallback =
@"function(s,e)
{
if(s.cp_RowInserted!=null)
{
alert('row inserted');
s.cp_RowInserted=null;
}
};";
关于c# - DevExpress gridView - 从 onRowInserted 事件触发 javascript 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841452/