RADGrid的问题

时间:2010-05-20 01:35:51

标签: telerik page-index-changed

我的页面中有radgrid。当我关闭视图状态并在pageindexchanged事件中单击下一页时,我什么都没得到。只是一个空白页面。但是当我打开视图状态时,我会在下一页中获取数据。有没有办法获取数据。由于性能问题,我无法打开视图状态。请参阅以下代码以供参考。

的.aspx

    <telerik:RadGrid ID="RadGrid1" OnSortCommand="RadGrid1_SortCommand" OnPageIndexChanged="RadGrid1_PageIndexChanged"
        AllowSorting="True" PageSize="20" ShowGroupPanel="True" AllowPaging="True" AllowMultiRowSelection="True"
        AllowFilteringByColumn="true" AutoGenerateColumns="false" EnableViewState="false" runat="server" GridLines="None"
        OnItemUpdated="RadGrid1_ItemUpdated" OnDataBound="RadGrid1_DataBound">

aspx.cs

public partial class _Default:System.Web.UI.Page {     protected void Page_Load(object sender,EventArgs e)     {         LoadData();     }

private void LoadData()
{
    SqlConnection SqlConn = new SqlConnection("uid=tempuser;password=tempuser;data source=USWASHL10015\\SQLEXPRESS;database=CCOM;");
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = SqlConn;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "usp_testing";
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    RadGrid1.DataSource = ds;
    RadGrid1.DataBind();
    //RadGrid1.ClientSettings.AllowDragToGroup = true;
}

protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
{
    //RadGrid1.Rebind();
    LoadData();
} 

1 个答案:

答案 0 :(得分:2)

尝试使用高级绑定挂钩NeedDataSource网格事件,如下所示: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx

因此,您应该可以关闭viewstate页面。

迪克