我的页面中有 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
公共部分类_默认: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();
}