ASPXGridView 自定义回调
我们有 DevExpress 网格,在 OnCustomCallback 事件中我们需要分配一个隐藏字段 value=true。之后我们需要将隐藏字段的值传递给javascript? 我们尝试了以下方式:
protected void dgUnReconcile_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
ASPxGridView temp = ((DevExpress.Web.ASPxGridView.ASPxGridView)(sender));
string gridInstancename = ((DevExpress.Web.ASPxGridView.ASPxGridView)(sender)).ClientInstanceName;
if (gridInstancename.Equals("grid"))
{
List<Object> selected = dgUnReconcile.GetSelectedFieldValues(new[] { "Key" });
if (selected.Count > 0)
{
existingKey = true;//hidden field value
}
}
}
我们需要通过 javascript
var ='<%#existingKey%>'; 访问隐藏字段值。
它总是显示空值。
We have the DevExpress grid and in the OnCustomCallback event we need to assign a hidden field value=true. After we need to get the hidden field value to javascript?
We tried in following manner:
protected void dgUnReconcile_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
ASPxGridView temp = ((DevExpress.Web.ASPxGridView.ASPxGridView)(sender));
string gridInstancename = ((DevExpress.Web.ASPxGridView.ASPxGridView)(sender)).ClientInstanceName;
if (gridInstancename.Equals("grid"))
{
List<Object> selected = dgUnReconcile.GetSelectedFieldValues(new[] { "Key" });
if (selected.Count > 0)
{
existingKey = true;//hidden field value
}
}
}
We need to access the hidden fields value through javascript
var ='<%# existingKey%>';
It always shows empty value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用网格的 JSProperties:
aspx:
在代码隐藏中设置值(C#):
获取客户端上的值(js):
Try to use the JSProperties of the grid:
aspx:
sets the value in code-behind (C#):
gets the value on client (js):
要在服务器端事件期间更改其他控件,您可能需要禁用回调(请参阅 ASPxGridView.EnableCallBacks 属性)并将隐藏字段和网格控件放入 UpdatePanel 中。
或者,如果您想保持回调启用,您可以使用 javascript 在客户端执行此操作。这里附加了一个类似的示例项目:
http://www.devexpress.com/支持/中心/p/Q201214.aspx
To change other controls during a server-side event, you might need to disable callbacks (see the ASPxGridView.EnableCallBacks property) and place both the hidden field and grid control into the UpdatePanel.
Alternatively, you can do it on the client-side with javascript if you want to keep callbacks enabled. There's a similiar sample project attached here:
http://www.devexpress.com/Support/Center/p/Q201214.aspx