2012-03-16 87 views
0

我有一个devexpress嵌套gridview。主控网格和详细网格视图都有用于编辑的链接按钮并添加新的活动。插入新行或更新现有行后,我必须显示一个消息框,指出“您的更新已成功保存”。这可能是一个简单的JavaScript警告框或页面上显示的消息本身。这两个gridviews都使用objectdatasource。我在Gridview和objectdatasource的RowUpdated事件中尝试了以下代码:如何显示消息框从编辑/添加新按钮点击devexpress gridview

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

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

但在任何情况下,都不显示消息框。如果我在页面上的按钮的按钮单击事件中使用了相同的代码,那么它工作正常。我的事件试图设置asp:Literal控件的文本值。它也没有工作。任何帮助是极大的赞赏。

感谢

回答

4

手柄ASPxGridView.RowInsertedASPxGridView.RowUpdated电网事件来设置消息包含自定义属性为ASPxGridView.JSProperties
然后处理客户端ASPxClientGridView.EndCallback事件来检查自定义属性是否存在并引发警报。

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事件相同。 DevEx支持中心有类似的example

或者,您可以使用use solution with e.command参数。

+0

这适用于master gridview。非常感谢你指导我朝着正确的方向发展。现在,我想通过警报框或通过网络控件(如标签或文字控件)发送消息来显示消息。 – user466663 2012-03-20 02:29:12

+0

@ user466663我用代码更新了答案。 – Filip 2012-03-20 13:10:01

相关问题