c# - DevExpress gridView - 从 onRowInserted 事件触发 javascript 警报

标签 c# javascript asp.net gridview devexpress

我在 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/

相关文章:

javascript - HTML 模板和 HTML 导入 - Firefox 中不执行内部脚本

javascript - JS : Collision Detection doesn't work when Ball is moving faster

c# - 如何在 C# 代码中使用 MongoDB 位置运算符?

c# - objective-c和C#的3DES加密结果不同

javascript - 在 div 中显示 json html 数据

asp.net - 我什么时候应该使用 Server.Transfer 而不是 PostBackURL?

c# - 我可以使用 Sql Server Express 复制和使用 mdf 文件吗?

asp.net - 在 Site.Master 中形成背景图像

C#Linq按组选择多列并同时在值字段上应用求和(聚合函数)

c# - 在 map/2d 数组中查找最近的(几何上)非零值