|
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Represents Products data
/// </summary>
public class ProductsList
{
public ProductsList()
{
//
// TODO: Add constructor logic here
//
}
public DataView GetProducts(int StartRow,int PageSize)
{
//this method Returns the Data from ProductsList.xml file
//getdata() could be implemented to read from database as well
return GetData(StartRow, PageSize);
}
private DataView GetData(int StartRow, int PageSize)
{
//this method reads data from xml file present in App_Code
DataSet Products = new DataSet();
Products.ReadXml(HttpContext.Current.Server.MapPath("~/App_Data/ProductsList.xml"));
DataTable ProductsTable= Products.Tables[0];
//create new empty table to hold the resultant rows
DataTable PagedProductsTable = ProductsTable.Clone();
//DataRow ProductsRow;
// i = NewPageIndex*PageSize gives us the starting row of new page
for (int i = StartRow; i < StartRow + PageSize && i < ProductsTable.Rows.Count; i++)
{
//add the rows
PagedProductsTable.ImportRow(ProductsTable.Rows[i]);
}
return PagedProductsTable.DefaultView;
}
public int GetRowsCount()
{
//this method returns the total number of rows in the xml file
DataSet Products = new DataSet();
Products.ReadXml(HttpContext.Current.Server.MapPath("~/App_Data/ProductsList.xml"));
return Products.Tables[0].Rows.Count;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I m a software developer working for about 2 years in the software industry. I have been focused primarily on .NET
I love to work develop for web using new technologies.
You will see more articles coming up about ASP.net 2.0.