Telerik asp.net ajax网格分页无法正常工作

时间:2015-09-07 07:08:25

标签: c# asp.net telerik telerik-grid

我制作了一个简单的购物车模块系统

enter image description here

当我点击第2页时,没有任何内容只显示我在此处上传的空白页

enter image description here

namespace PaymentGateWay
{
    public partial class Payments : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 if (!IsPostBack)
            {

                readcoupons();
               // dt = new DataTable();
               // DataTable dtn = new DataTable();

               // dt.Columns.Add("chkstatus");
               // dt = dtn;ViewState["dt"]
                ViewState["dt"] = "NULL";

            }

 }

   private void readcoupons()
        {

            BAL.READDATA readcoupons = new READDATA();
            DataSet ds = readcoupons.ReadCoupons();
            rg_coupons.DataSource = ds.Tables[0];
            rg_coupons.DataBind();



        }

1 个答案:

答案 0 :(得分:1)

您必须在其NeedDataSource事件中向RadGrid提供数据源,而不是仅在初始页面加载时提供。

服务器代码:

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    BAL.READDATA readcoupons = new READDATA();
    DataSet ds = readcoupons.ReadCoupons();
    rg_coupons.DataSource = ds.Tables[0];
}

标记:

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"></telerik:RadGrid>`enter code here`