c# - List (Generic) using jquery -
i have webmethod in asp.net project wanna pass listview in jquery ajax method dont how can observe elements of listview , using them.folowing code c# code.bt need jquery code
if (ck != null) { reqnum[0, 0] = "@requestingbranchid"; reqnum[0, 1] = ck["branchid"]; reqnum[1, 0] = "@providerbranchid"; reqnum[1, 1] = customer.tostring(); datatable dt = sqlcommands.filldata(out outstatus, out outmessage, "bsd.sw_boxes_stockofproviderandrequestingbranch", commandtype.storedprocedure, reqnum); list<datarow> rows = dt.rows.cast<datarow>().tolist(); int x=rows.count; homecoming rows; }
ok let's have datatable
, want pass results of datatable
javascript display results using ajax
. first step need convert these results json format. can next method::
public string getjson(datatable dt) { system.web.script.serialization.javascriptserializer serializer = new system.web.script.serialization.javascriptserializer(); list<dictionary<string, object>> rows = new list<dictionary<string, object>>(); dictionary<string, object> row = null; foreach (datarow dr in dt.rows) { row = new dictionary<string, object>(); foreach (datacolumn col in dt.columns) { row.add(col.columnname, dr[col]); } rows.add(row); } homecoming serializer.serialize(rows); }
the next step parse result json string in javascript , guess easy part. can check question find out how parse json string objects safely turning json string object .if u want know more tell me.
c# asp.net jquery
No comments:
Post a Comment