ASP.NET - how to bind gridview at client side ,gridview contains template field

Asked By p on 29-Jun-12 07:14 AM
bind gridview with jquery
Lalit M replied to p on 29-Jun-12 07:18 AM
Check this link :-> http://www.stackdotnet.com/2012/04/client-side-binding-of-gridview-and.html
Jitendra Faye replied to p on 29-Jun-12 08:12 AM
Reference from-

http://weblogs.asp.net/ahmedmoosa/archive/2010/10/30/bind-gridview-using-jquery.aspx
solution-


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</
script>
<script type="text/javascript">
  function BindGridView() {
   $.ajax({
      type:
"POST",
      url:
"Default.aspx/GetNames",
      data:
"{}",
      contentType:
"application/json",
      dataType:
"json",
      success:
function (data) {
     for (var i = 0; i < data.d.length; i++) {
        $(
"#NamesGridView").append("<tr><td>" + data.d[i].FirstName + 
                       
"</td><td>" + data.d[i].Age + "</td></tr>");
       }
       }
      })
    }
</script>

bharti odedra replied to p on 29-Jun-12 08:32 AM
try this code

using System;
using System.Data

public partial class_Default : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
  BindGrid();
}
private void BindGrid()
{
DataTable table = GetData();
grdClient.DataSource = table;
grdClient.DataBind();
}

private static DataTable GetData()
{
DataTable table = new DataTable90;
table.Columns.add("janAmount",typeof(decimal));
table.Columns.add("FebAmount",typeof(decimal));
table.Columns.add("marAmount",typeof(decimal)); 

table.Rows.add(0,0,0);

return table;
}
}