Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to bind data to gridview with jquery in

In previous articles i have given Cascading dropdownlist using jquery .In this post i would like to explain how to bind data to gridview using Jquery. Here we can observe the page method calling using jquery post method
<html xmlns="">
<head runat="server">
<title>Bind data to grid using jquery in</title>
<script src=></script>
<script type="text/javascript">
$(document).ready(function () {
type: "POST",
contentType: "application/json; charset=utf-8",
url: "JqueryBindGrid.aspx/BindOrderDataToGrid",
data: "{}",
dataType: "json",
success: function (resData) {
    for (var i = 0; i < resData.d.length; i++) {
        $("#GvOrderDetails").append("<tr><td>" + resData.d[i].OrderId + "</td><td>" + resData.d[i].OrderName + "</td><td>" + resData.d[i].Phone + "</td><td>" + data.d[i].Address + "</td><td>" + resData.d[i].Amount + "</td></tr>");
error: function (result) {
<form id="form1" runat="server">
<asp:GridView ID="GvOrderDetails" runat="server">
Code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web.Services;

public partial class JqueryBindGrid : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
DataTable GVHeaderdt = new DataTable();
GvOrderDetails.DataSource = GVHeaderdt;

public class OrderReportDetails
public int OrderId { get; set; }
public string OderName { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string Amount { get; set; }
public static OrderReportDetails[] BindOrderDataToGrid()
DataTable resDt = new DataTable();
List ORdetails = new List();
SqlConnection Dbcon = new SqlConnection(ConfigurationManager.AppSettings["DbOrdrCon"].ToString());
SqlCommand cmd = new SqlCommand("select * from Orders", Dbcon);
SqlDataAdapter Orda = new SqlDataAdapter(cmd);
foreach (DataRow Ordt in resDt.Rows)
OrderReportDetails OrderDetails = new OrderReportDetails();
OrderDetails.OrderId = int.Parse(Ordt["OrderId"].ToString());
OrderDetails.OderName = Ordt["OrderName"].ToString();
OrderDetails.Phone = Ordt["Phone"].ToString();
OrderDetails.Address = Ordt["Address"].ToString();
OrderDetails.Amount = Ordt["Amount"].ToString();
return ORdetails.ToArray();


This post first appeared on Aspdotnet-Sharepoint, please read the originial post: here

Share the post

How to bind data to gridview with jquery in


Subscribe to Aspdotnet-sharepoint

Get updates delivered right to your inbox!

Thank you for your subscription