public string DataSet(string searchField1, string searchOper1, string searchString1, int page1, string pageSize1, string sortIndex1, string sord1, int totalrows1) { clsDataHandling objDataClass = new clsDataHandling(); DataTable dt = null; dt = objDataClass.DataSet(); int page = page1; // Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString()); string sidx = sortIndex1; // HttpContext.Current.Request.QueryString["sidx"].ToString(); string sord = sord1; // HttpContext.Current.Request.QueryString["sord"].ToString(); int totalRows = totalrows1; // Convert.ToInt32(HttpContext.Current.Request.QueryString["totalrows"].ToString()); string searchField = searchField1; // HttpContext.Current.Request.QueryString["SEARCHFIELD"]; string searchString = searchString1; // HttpContext.Current.Request.QueryString["SEARCHSTRING"]; string searchOper = searchOper1; // HttpContext.Current.Request.QueryString["SEARCHOPER"]; if (page == 0) { page = 1; } string result = ""; if (String.IsNullOrEmpty(sidx)) { sidx = "1"; } int count; result = dt.Rows.Count.ToString(); count = dt.Rows.Count; int totalpages; Int32 limit = 0; if (pageSize1 == "All") { limit = Convert.ToInt32(result); } else { limit = Convert.ToInt32(pageSize1);// pageSize1;// Convert.ToInt32(HttpContext.Current.Request.QueryString["rows"].ToString()); } double hasilbagi = Convert.ToDouble(result) / Convert.ToDouble(limit); if (int.Parse(result) > 0) { totalpages = Convert.ToInt32(Math.Ceiling(hasilbagi)); } else { totalpages = 0; } if (Convert.ToInt32(page) > totalpages) { page = totalpages; } int start = limit * page - limit; if (start < 0) { start = 0; } string strFilter = objDataClass.SetSearchStr(searchOper, searchField, searchString); string strSort = sidx + " " + sord; DataRow[] dr = dt.Select(strFilter, strSort); DataTable dtNew; StringBuilder stringBuilder = new StringBuilder("{"); stringBuilder.Append("total: " + totalpages + ", "); stringBuilder.Append("page: " + page + ", "); stringBuilder.Append("records: " + count + ", "); stringBuilder.Append(" rows : [ "); if (dr.Length > 0) { dtNew = dr.CopyToDataTable <DataRow>(); for (int i = start; i < dt.Rows.Count; i++) { if (i < dtNew.Rows.Count) { stringBuilder.Append("{"); stringBuilder.Append("id:" + i + ", "); stringBuilder.Append("cell:[ "); stringBuilder.Append("'" + dtNew.Rows[i][0] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][1] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][2] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][3] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][4] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][5] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][6] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][7] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][8] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][9] + "'" + ","); stringBuilder.Append("'" + dtNew.Rows[i][10] + "'" + ""); stringBuilder.Append(" ]"); if (i == dt.Rows.Count - 1) { stringBuilder.Append(" }"); } else { stringBuilder.Append(" },"); } } } } stringBuilder.Append(" ]"); stringBuilder.Append(" }"); return(stringBuilder.ToString()); }