[id] INT IDENTITY (1, 1) NOT NULL, [code] VARCHAR (55) NOT NULL, [name] VARCHAR (55) NOT NULL, [image] VARCHAR (55) DEFAULT (NULL) NULL, [parent_id] INT DEFAULT (NULL) NULL, [slug] VARCHAR (55) DEFAULT (NULL) NULL, [updated_at] DATETIME2 (0) DEFAULT (getdate()) NOT NULL, PRIMARY KEY CLUSTERED ([id] ASC)
int intSkip = 0, i = 0; intSkip = (this.currentPage * this.pageSize); string query = "SELECT * FROM lwpos_categories"; string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString; SqlConnection con = new SqlConnection(cs); SqlCommand cmd = new SqlCommand(query, con); cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader sdr = cmd.ExecuteReader(); DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("lwpos_categories"); // Add the table columns. for (i = 0; i < sdr.FieldCount; i++) {
dt.Columns.Add(sdr.GetName(i), sdr.GetFieldType(i));
} int intIdx = 0; while (sdr.Read()) {
if (intIdx >= intSkip)
{
DataRow row = dt.NewRow();
// Assign DataReader values to DataRow.
for (i = 0; i < sdr.FieldCount; i++) { row[i] = sdr[i]; }
for (i = 0; i < sdr.FieldCount; i++)
row[i] = sdr[i];
}
dt.Rows.Add(row);
if ((intIdx - intSkip) >= (this.pageSize - 1)) { break; }
if ((intIdx - intSkip) >= (this.pageSize - 1))
break;
intIdx++;
} sdr.Close(); // Populate Data Grid this.CategoryGV.DataSource = ds.Tables["lwpos_categories"].DefaultView; // Show Status this.txtPageStatus.Text = "Showing Page: " + (this.currentPage + 1).ToString() + " of " + this.pageCount.ToString(); cmd.Dispose(); ds.Dispose(); con.Close();
// For Page view. this.pageSize = intPageSize; this.totalRecords = getNoOfRecords(); this.pageCount = this.totalRecords / this.pageSize; // Adjust page count if the last page contains partial page. if (this.totalRecords % this.pageSize > 0) {
this.pageCount++;
} this.currentPage = 0; loadPage();