Search code examples
c#asp.netteleriktelerik-grid

Telerik asp.net ajax grid pagination not working


I have made a simple cart module system

enter image description here

when i click the page no 2 nothing is displaying just a blank page which i am uploading it here

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



        }

Solution

  • You must provide a data source to RadGrid in its NeedDataSource event and not on initial page load only.

    server code:

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

    markup:

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