最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - ASPXGridView Custom CallBack - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Oct 2, 2009 at 19:41 Greg 16.7k9 gold badges54 silver badges100 bronze badges asked Sep 30, 2009 at 17:21 subramanisubramani 1,0695 gold badges13 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2 +50

Try to use the JSProperties of the grid:

aspx:

<dxwgv:ASPxGridView ID="myGridView" ClientInstanceName="myGridView" runat="server">
</dxwgv:ASPxGridView>

sets the value in code-behind (C#):

myGridView.JSProperties["cpMyValue"] = "hello, world!";

gets the value on client (js):

alert(myGridView.cpMyValue);

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./Support/Center/p/Q201214.aspx

发布评论

评论列表(0)

  1. 暂无评论