Rows is the number of rows sent by the client, page is the page number, the argument requires two parameters on the line, SQL statements _row and _page their own declared local variables, the value or the corresponding row and page, in order to calculate just.
Use the database class to get its DataTable, convert the JSON format to the client via a generic handler, and the client displays OK. Here I use the Easyui DataGrid for receiving and passing parameters. This is the general idea.
String sql = ' Select top ' + Rows + ' * from TestData where TestID not in (select Top + (_rows * (_page-1)) + "TestID From TestData-TestID desc) Order BY testid Desc ";
The DataTable is converted to JSON, where the total is taken, the number of data passed to the client is not transmitted, and the client does not show how many items the total data is. public static string Createjsonparameters (DataTable DT, bool displaycount, int totalcount) {StringBuilder jsons
Tring = new StringBuilder ();
Exception handling if (dt!= null) {Jsonstring.append ("{");
if (displaycount) {jsonstring.append ("\" total\ ":");
Jsonstring.append (TotalCount);
Jsonstring.append (",");
} jsonstring.append ("\" rows\ ": ["); for (int i = 0; i < dt. Rows.Count;
i++) {jsonstring.append ("{"); for (int j = 0; j < dt.) Columns.count; J + +) {if (J < dt. columns.count-1) {//if (dt.
ROWS[I][J] = = DBNull.Value) continue; if (dt. COLUMNS[J]. DataType = = typeof (bool)) {jsonstring.append ("\" + dt. COLUMNS[J]. ColumnName + "\": "+ dt." ROWS[I][J]. TostrinG ().
ToLower () + ","); else if (dt. COLUMNS[J]. DataType = = typeof (String)) {jsonstring.append ("\" + dt. COLUMNS[J]. ColumnName + "\": "+" \ "" + dt. ROWS[I][J]. ToString ().
Replace ("\" "," \\\ ") +" \ ","); else {jsonstring.append ("\" + dt.) COLUMNS[J]. ColumnName + "\": "+" \ "" + dt.
ROWS[I][J] + "\", "); ' Else if ' (j = = dt. columns.count-1) {//if (dt.
ROWS[I][J] = = DBNull.Value) continue; if (dt. COLUMNS[J]. DataType = = typeof (bool)) {jsonstring.append ("\" + dt. COLUMNS[J]. ColumnName + "\": "+ dt." ROWS[I][J].
ToString ()); else if (dt. COLUMNS[J]. DataType = = typeof (String)) {jsonstring.append ("\" + dt. COLUMNS[J].
ColumnName + "\": "+" \ "" + Dt. ROWS[I][J]. ToString ().
Replace ("\" "," \\\ ") +" ""); else {jsonstring.append ("\" + dt.) COLUMNS[J]. Columnname+ "\": "+" \ "+ dt.
ROWS[I][J] + "" ""); }}/*end of string*/if (i = = dt.
rows.count-1) {jsonstring.append ("}");
else {jsonstring.append ("},");
} jsonstring.append ("]");
Jsonstring.append ("}"); Return jsonstring.tostring ().
Replace ("\ n", "");
else {return null;
}
}
The above is the entire content of this article, I hope to help you learn.