本文介绍了如何显示从编辑一个消息框/加devex preSS的GridView的新按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个devex preSS嵌套的GridView。无论主从GridView的有编辑链接按钮,并添加新的活动。无论是插入新行或更新现有行之后,我必须展示一个消息框,说:您的更新已成功保存。这可能是一个简单的JavaScript警告框或页面本身上显示的消息。无论是GridView的使用ObjectDataSource控件。我尝试以下codeS在GridView和ObjectDataSource控件双方的RowUpdated事件:

I have a devexpress nested gridview. Both the master and detail gridviews have link buttons for edit and add new activities. After either inserting new row or updating an existing row, I have to show a message box saying "Your update has been saved successfully". This could be a simple javascript alert box or a message displayed on the page itself. Both the gridviews use objectdatasource. I tried the following codes in the RowUpdated event of both the gridview and the objectdatasource:

System.Web.HttpContext.Current.Response.Write(警告(你的更新已经成功保存'));

System.Web.HttpContext.Current.Response.Write("alert(Your updated has been saved successfully')");

ClientScript.RegisterStartupScript(this.GetType(),myalert,警报('+您的更新已成功保存+');,真正的);

ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + Your updated has been saved successfully+ "');", true);

但是,在这两种情况下,不显示消息框。如果我用同样的code在页面上的按钮,按钮点击事件,那么它工作正常。我试着事件设置一个ASP的文本值:文字控制。它也没有工作。任何帮助是极大的AP preciated。

But in either case, no message box is displayed. If I used the same code in the button click event of a button on the page, then it works fine. I event tried to set the text value of a asp:Literal control. It also didn't work. Any help is greatly appreciated.

感谢

推荐答案

处理<一个href=\"http://documentation.devex$p$pss.com/#AspNet/DevEx$p$pssWebASPxGridViewASPxGridView_RowInsertedtopic\"相对=nofollow> ASPxGridView.RowInserted 和<一个href=\"http://documentation.devex$p$pss.com/#AspNet/DevEx$p$pssWebASPxGridViewASPxGridView_RowUpdatedtopic\"相对=nofollow> ASPxGridView.RowUpdated 网格事件来设置包含的消息到<自定义属性href=\"http://documentation.devex$p$pss.com/#AspNet/DevEx$p$pssWebASPxGridViewASPxGridView_JSPropertiestopic\"相对=nofollow> ASPxGridView.JSProperties 。结果
然后处理客户端<一个href=\"http://documentation.devex$p$pss.com/#AspNet/DevEx$p$pssWebASPxGridViewScriptsASPxClientGridView_EndCallbacktopic\"相对=nofollow>检查ASPxClientGridView.EndCallback 的事件,如果自定义属性存在,并提高警觉。

Handle ASPxGridView.RowInserted and ASPxGridView.RowUpdated grid events to set custom property containing message into ASPxGridView.JSProperties.
Then handle client side ASPxClientGridView.EndCallback event to check if custom property exists and raise alert.

protected void ASPxGridView1_RowUpdated(object sender, ASPxDataUpdatedEventArgs e) {
    if (e.Exception == null) {
        ((ASPxGridView)sender).JSProperties["cpUpdatedMessage"] = "Your update has been saved successfully";
    }
}
<dx:aspxgridview ID="ASPxGridView1" ... onrowupdated="ASPxGridView1_RowUpdated">
    <clientsideevents
        EndCallback="function(s, e) {
                        if (s.cpUpdatedMessage) {
                            alert(s.cpUpdatedMessage);
                            delete s.cpUpdatedMessage;
                        }
                    }"
    />

做RowInserted事件相同。
有类似。

另外,您也可以与e.command 参数。

Alternatively, you can use solution with e.command parameter.

这篇关于如何显示从编辑一个消息框/加devex preSS的GridView的新按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!