ASPxGridView分页问题

时间:2011-12-28 12:01:09

标签: asp.net callback devexpress aspxgridview

我的项目中有一个ASPxGridView和2个单选按钮。当我更改单选按钮组的选择时,它会更改数据源的选择命令。之后,当我点击第二页时,数据源的选择命令将变为先前的情况。

这是一个例子.. http://www.2shared.com/file/HwnBYcFS/WebApplication8.html

注意:当页面加载数据源过滤器的Neo时,单击“全部”单选按钮,然后更改页面。

感谢您的回答..

1 个答案:

答案 0 :(得分:2)

1.add init事件处理程序到网格
2.implement init事件处理程序

protected void Grid_Init(object sender, EventArgs e)
{
    if (!IsCallback)
        Page.Session["selectCommand"] = null;

    if (Page.Session["selectCommand"] != null)
        AccessDataSource1.SelectCommand = (string)Page.Session["selectCommand"];
    grid.DataBind();
}

3.更改自定义回调处理程序

protected void grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
    if (e.Parameters == "Neo")
    {
        AccessDataSource1.SelectCommand = "select Name,Surname from Person where Name='Neo'";
    }
    else if (e.Parameters == "All")
    {
        AccessDataSource1.SelectCommand = "select Name, Surname from Person";
    }
    Page.Session["selectCommand"] = AccessDataSource1.SelectCommand;
    grid.DataBind();
}

4.使用CheckedChange客户端事件而不是gotfocus

<ClientSideEvents CheckedChanged="
    function(s, e)         
    {
        if(s.GetValue())
            grid.PerformCallback(&quot;Neo&quot;);
    }" />
相关问题