Neo Neo - 1 year ago 116
ASP.NET (C#) Question

display only first 10 records from array using c# jquery


$(document).ready(function () {

type: "POST",
url: "Index.aspx/GetData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {

$.each(msg.d, function (index, value) {

return false;



public static IEnumerable<TemperatureEntity> GetData()
//return array data

I have traverse through array and want to display it in tabular format on html like email,phonenumber.
enter image description here
enter image description here

Answer Source

If you want to do it exaclty on the client side then check the slice() jQuery function

You should modify your code as following:

var slicedData = msg.d.slice(0, 10);
$.each(slicedData, function (index, value) {
                    var html = $('#myDiv').html();
                    html += value.Email;
                    html += value.PhoneNumber;
                    $('#myDiv').html(html + '<br />');

But if you can modify the resulting array on the server side - do it on server side with Linq method Take(10);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download