0
votes

In SharePoint 2010 I need to get list items from a list and bind it to either DataView web part or SPGridView control on page. I need to do this using client object model (jquery). I am familiar with retrieving list data using client object model. Not sure how to bind data to DataView web part or GridView. Any idea?

1

1 Answers

2
votes

do you need to to call the method asynchronously? I'm wondering why you need to use jQuery/javascript.

Anyway, what you can do is append the and to the grid view. For example,

//code to get the data

for(var i = 0; i < data.length; i++) {
   $("#NamesGridView").append("<tr><td>" + data.d[i].FirstName + "</td><td>" + data.d[i].Age + "</td></tr>");
   }
}

//your code would

<asp:GridView ID="NamesGridView" runat="server" ShowHeaderWhenEmpty="True">
</asp:GridView>

You can look at this article (http://weblogs.asp.net/ahmedmoosa/archive/2010/10/30/bind-gridview-using-jquery.aspx)

I hope this helps you!