RADGrid 的问题
我的页面中有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用高级绑定挂钩 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