Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
heyy..

I use ajax jquery gridview to load a large amount of data..but the grid does not load..if less amount of data came the grid will display....otherwise it is not displayed...

So how to handle the large amount of data to display in ajax gridview...here is my code...

C#
// showing bill details
    function ShowBillDetails(control)
    {
        $('#divGrid').html('');
        $('#divGrid').hide();
        $('#DisableDiv').show();
        var phoneNumber = $(control).attr('PhoneNumber').toString();
        showBillDialog();
        setTimeout(function() { ShowBills(phoneNumber) },3000);
    return false;
}


// for show the data in grid
function ShowBills(phoneNumber) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "LinkingCustomers.aspx/GetBillData",
        data: "{'phoneNumber':'" + phoneNumber + "'}",
        dataType: "json",
        success: function(data) {
        var theHtml = data.d;
        $('#divGrid').show();
            $('#divGrid').html(theHtml)
            $('#DisableDiv').hide();
        } 
        ,
        error: function(result) {
            alert(result);
        }
    }); 
}


code.cs
---------
#region WebMethods

       [WebMethod]
       public static string GetBillData(string phoneNumber)
       {
               GridView gv = new GridView();
               System.IO.StringWriter stringWriter = new System.IO.StringWriter();
               HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
               DataTable objDT = new DataTable();
               objDT = LinkingCustManager.GetBillData(phoneNumber);
               //var result = from n in objDT.AsEnumerable().Take(5) select n;
               gv.CssClass = "gridtable";
               gv.DataSource = objDT;
               gv.DataBind();
               gv.RenderControl(htmlWriter);
               return stringWriter.ToString();

       }
       #endregion
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900