I could successfully populate gridview with jquery like
<asp:GridView ID="NamesGridView" runat="server" ShowHeaderWhenEmpty="True" >
</asp:GridView>
<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>
[WebMethod]
public static Names[] GetNames()
{
List<Names> list = new List<Names>();
DataTable dt = DataStore.GetDataTable();
foreach (DataRow row in dt.Rows)
{
Names _names = new Names();
_names.FirstName = row["Name"].ToString();
_names.Age = row["age"].ToString();
list.Add(_names);
}
return list.ToArray();
}
with the above code I can populate gridview with jquery but if my gridview has pager row then I think my code may not work perfectly because my code always append a table row at the end of gridview and if pager is there at the bottom then how can I append rows in between pager I mean before pager row?
can't i return only list like return list instead of return list.ToArray();