RADGrid 的问题

发布于 2024-09-02 08:12:08 字数 1459 浏览 3 评论 0 原文

我的页面中有 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(对象发送者,EventArgs e) { 加载数据(); }

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();
} 

I Have radgrid in my page. When i turn off view state and in pageindexchanged event when click next page i am getting nothing. Simply a blank page. But when i turn on view state I am getting data in next pages. Is there any way to get the data. I cant turn on the view state due to performance issue. Please see the code below for the reference.

.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();
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一城柳絮吹成雪 2024-09-09 08:12:08

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

因此,您应该能够在关闭视图状态的情况下进行分页。

迪克

Try with advanced binding hooking the NeedDataSource grid event as shown on this sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx

Thus you should be able to page with viewstate off.

Dick

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文