c# - how can i read a DataTable from javascript -


i have function return datatable :

public datatable sendonlinecontacts() {  ...     (int = 0; < friendsdt.rows.count; i++)         {             int friendid = convert.toint16(friendsdt.rows[i][0]);                 datarow[] friendisonlinerow = connectedclientdt.select("clientid=" + friendid);                  if (friendisonlinerow.length > 0)  // friend online                  {                   //  new sqlhelper(sqlhelper.connectionstrings.websiteconnectionstring).update("update clients set user_status='o' client_id=" + friendsdt.rows[i][0]);                     friendsinfo.rows.add(friendsdt.rows[i][0] + "," + friendsdt.rows[i][1] + "," + friendsdt.rows[i][2] + "," + "o");                   }            }             return friendsinfo;      } 

client side :

$.ajax({     type: 'post',     url: 'chatpagetest.aspx/sendonlinecontacts',     data: '{}',     contenttype: 'application/json; charset=utf-8',     datatype: 'json',     success: function (data) {      // here read datatable ??      }       ... 

please , thank u

try this:

public object[][] sendonlinecontacts() {     //...     (int = 0; < friendsdt.rows.count; i++)     {         int friendid = convert.toint16(friendsdt.rows[i][0]);         datarow[] friendisonlinerow = connectedclientdt.select("clientid=" + friendid);          if (friendisonlinerow.length > 0)  // friend online          {             //  new sqlhelper(sqlhelper.connectionstrings.websiteconnectionstring).update("update clients set user_status='o' client_id=" + friendsdt.rows[i][0]);             friendsinfo.rows.add(friendsdt.rows[i][0] + "," + friendsdt.rows[i][1] + "," + friendsdt.rows[i][2] + "," + "o");         }     }      var rows = friendsinfo.rows         .oftype<datarow>()         .select(row => row.itemarray)         .toarray();     return rows; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -