| Author: chandramohan 23 Jun 2008 | Member Level: Gold | Rating: Points: 1 |
Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim myConnection As New _ SqlConnection(ConfigurationSettings.AppSettings("connectionString")) Dim myDA As New SqlClient.SqlDataAdapter("Select * from dtsDefect", _ myConnection) myDA.Fill(ds, "t1") pageds.DataSource = ds.Tables("t1").DefaultView pageds.AllowPaging = True pageds.PageSize = 4 Dim curpage As Integer
If Not IsNothing(Request.QueryString("Page")) Then curpage = Convert.ToInt32(Request.QueryString("Page")) Else curpage = 1 End If
pageds.CurrentPageIndex = curpage - 1 lblCurrpage.Text = "Page: " + curpage.ToString()
If Not pageds.IsFirstPage Then lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + _ "?Page=" + CStr(curpage - 1) End If
If Not pageds.IsLastPage Then lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + _ "?Page=" + CStr(curpage + 1) End If
Repeater1.DataSource = pageds Repeater1.DataBind() End Sub ---------------------------------
System.Web.UI.WebControls.PagedDataSource pgds = new System.Web.UI.WebControls.PagedDataSource (); pgds.DataSource = _data; pgds.AllowPaging = true; pgds.PageSize = 12; DataList1.DataSource = pgds;
|
| Author: Shivshanker Cheral 23 Jun 2008 | Member Level: Diamond | Rating: Points: 6 |
It should be noted that, like DataGrid, DataList does not support inbuilt paging mechanism. The essence of this article is how we make use of the object SqlDataAdapter. This object has a method called, Fill which is used to add or refresh the rows in a DataSet. Actually the method Fill is overloaded. We will be mainly concentrating the one which takes four arguments. The four arguments are DataSet, startRecord, maxRecords and the TableName. Second and third arguments are integer. Where as the TableName is the table name. So, if we say objDV.Fill(objDS, 0, 5, "sales"). The dataset will be filled with 5 records and the starting position will be from the first record. First, we are bringing the entire records from the table sales, and then we filter those with the help of startRecord and maxRecords.
refer for more http://aspalliance.com/articleViewer.aspx?aId=157&pId=
http://www.codeproject.com/KB/aspnet/DataListPaging.aspx
|