我的页面上有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

公共部分类_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();
} 
有帮助吗?

解决方案

尝试使用高级绑定挂钩,如本示例所示:http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx

因此,您应该能够与ViewState关闭。

迪克

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top