private void Query ()
{
Database db = new database ();
DataTable datatable = db. Getdatatable ("SELECT top * from table where Productsno like ' ba01% '");
This. Datalisttp.datasource = dataTable;
This. DataBind ();
PagedDataSource Objpds = new PagedDataSource ();
Objpds.datasource = ds. Tables[0]. DefaultView;
Objpds.allowpaging = true;
Objpds.pagesize = 15;
int curpage;
int PageCount = ds. Tables[0]. Rows.count/objpds.pagesize;
if (ds. Tables[0]. Rows.Count% Objpds.pagesize > 0)
{
pagecount++;
}
if (request.querystring["Page"]!= null)
Curpage = Convert.ToInt32 (request.querystring["Page");
Else
Curpage = 1;
Objpds.currentpageindex = CurPage-1;
This. Label1.Text = "First" + curpage.tostring () + "page Total" + pagecount.tostring () + "page";
if (!objpds.isfirstpage)
{
Lnkprev.navigateurl = Request.currentexecutionfilepath + "? Page= "+ convert.tostring ((CurPage-1));
}
Else
{
Lnkprev.enableviewstate = false;
}
if (!objpds.islastpage)
{
Lnknext.navigateurl = Request.currentexecutionfilepath + "? Page= "+ convert.tostring (curpage + 1);
}
Else
{
Lnknext.enableviewstate = false;
}
}
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;
Using system.data.sqlclient;//reference Sqlclicent class
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
This. DataBind ();
}
private override void DataBind ()
{
String constr = "server=local;uid=sa;pwd=;D atabase=**";
SqlConnection con = new SqlConnection (CONSTR);//Connect database
String sqlstr = "SELECT * FROM table";
SqlDataAdapter SDA = new SqlDataAdapter (Sqlstr,con);
DataSet ds=new DataSet ();
Sda. Fill (DS)//Data set
Datalist1.datasource = ds;
Datalist1.databind ();
}
}