C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Paging in DataList


Posted Date: 23 Jun 2008      Total Responses: 2

Posted By: yasher araabath       Member Level: Bronze     Points: 1



How to give Paging in DataList?




Responses

Author: chandramohan    23 Jun 2008Member Level: GoldRating:     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 2008Member Level: DiamondRating:     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



Post Reply
You must Sign In to post a response.
Next : When constructing an XML DTD, how do you create an external entity reference in an attribu
Previous : Disable Save Option For an Image
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use