views:

2509

answers:

2

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.

A: 

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

Greg
A: 

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);
Jo Asakura