开发者

How to parse json and populate gridview with jquery

    [WebMethod]
    public static List<Employee> GetData()
    {

        List<Employee> oEmployee = new List<Employee>
        {
               new Employee("Arijit","Accounts",23000,'01/01/2001'),
               new 开发者_如何学编程Employee("Tridip","Sales",15000,'01/01/2005'),
               new Employee("Dibyendu","IT",16000,'01/01/2002'),
               new Employee("Somjit","TAX",12000,'01/01/2012'),
               new Employee("Amit","Purchase",13000,'01/01/2010'),

        };
        return oEmployee;

    }

We have class called employee it has some property like

Name  string
DepartmentName string
Salary double
JoinDate datetime

So when i will call the GetData(0 function by jquery then this function return result in json format and when we get the data from client side then how could parse this json data and populate my gridview.

My gridview has 4 <ItemTemplate> and in each <ItemTemplate> has label for hoding json data like name salary etc.

So, just please provide me the code which will parse json and populate gridview rows in loop with json data. If 10 record return from server side then from the client side gridview will be populated with 10 records parsing json through jquery and add rows to my gridview. please help for the client side jquery script will will parse json and populate gridview.......thanks


I think you better to use a feature called "JQuery Templates". more information with a good example can be found here

http://weblogs.asp.net/hajan/archive/2010/12/13/jquery-templates-in-asp-net-introduction.aspx

and here is a more of an advanced example: http://weblogs.asp.net/dwahlin/archive/2009/05/03/using-jquery-with-client-side-data-binding-templates.aspx


you can use jquery templates.This will be a help http://www.borismoore.com/2010/09/introducing-jquery-templates-1-first.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜