Hi!
I have a User Control which displays messages of the user. It displays the messages sent and received by user.
I am populating the data from database using API method and assigning it to the dataset.
Here am using asp.net nested repeater. The outer repeater displays the first message from each person (i.e., only one message per person).
If u click on the message, it takes to another page where it displays all the conversation of the user. here am displaying the inner repeater (its like iPhone messages app).
It is working fine. Now I need to add paging to this app, both for the outer repeater and the inner repeater.
I tried using a "PagedDataSource" to do this, but in my dataset i will get a all the messages of the user.
Am not able to filter the data source for outer repeater as well as inner repeater.
So, am not able to assign the paging correctly to the repeater.
Can some tell me how to apply paging to both outer and inner repeater.
Thank You,
Naresh
NareshPosted Jun 21, 2011, 1:21 PM
Thank you guys for the reply.
I think, I didn't explained the problem correctly.
My problem is with paging. Am able to display the data properly, my requirement got changed to use paging for displaying messages. when it comes to paging I am using paged data source,
I have a data set which has all messages of current user from other users. The parent repeater displays all senders with their latest message, when user click on that latest message it displays all messages from that user in the child repeater. In parent repeater Itemdatabound I am adding each user to arraylist, if user already not in arraylist, to display distinct users(since Messages dataset has all messages from all users to the current user).I am using same dataset to both parent and child repeaters.
Here am attaching the screen shots of my app.
The "Pic 1" is the landing page, where it displays the latest messages from the users.
If the user clicks on the subject link of a particular message, it displays the "Pic 2", where all the messages of current user with that particular user are shown.
It just looks like the messages app in iPhone.
I need to apply paging for both the parent and child repeater.
So, can any one have an idea of how to do this?
Your help is appreciated.
Thank You,
Naresh
Pankaj GogoiPosted Jun 18, 2011, 4:20 AM
Here is one sample code to give you an idea.
Private table As New DataTable()
Private PDS As New PagedDataSource()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
InitData()
End If
End Sub
Private Sub InitData()
Dim conn As New SqlConnection("Data Source=Localhost;Initial Catalog=Northwind;User ID=sa")
Dim cmm As New SqlCommand("SELECT [CustomerID], [CompanyName] FROM [Customers]")
cmm.Connection = conn
Dim DA As New SqlDataAdapter()
DA.SelectCommand = cmm
Dim DS As New DataSet()
DA.Fill(DS)
table = DS.Tables(0)
If Session("data") IsNot Nothing Then
Session("data") = table
Else
Session.Add("data", table)
End If
Pagging(0)
End Sub
Protected Sub Pagging(ByVal index As Integer)
PDS.DataSource = DirectCast(Session("data"), DataTable).DefaultView
PDS.CurrentPageIndex = index
PDS.AllowPaging = True
PDS.PageSize = 20
Me.Repeater2.DataSource = PDS
Me.Repeater2.DataBind()
Dim ddl As DropDownList = DirectCast(Me.Repeater2.Controls(Me.Repeater2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
If ddl IsNot Nothing Then
For i As Integer = 1 To PDS.PageCount - 1
ddl.Items.Add(i.ToString())
Next
End If
End Sub
Public Sub PageIndex(ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = DirectCast(Me.Repeater2.Controls(Me.Repeater2.Controls.Count - 1).FindControl("PageCount"), DropDownList)
Pagging(Integer.Parse(ddl.SelectedItem.Text) - 1)
End Sub
Select page
Here are some links with paging in repeater using pageddatasource. Hope you find your solution withing this articleshttp://www.4guysfromrolla.com/articles/081804-1.aspx
http://www.codeproject.com/Kb/aspnet/pagingBySreejith%20Thathanattu.aspx
Thank You
Jiteendra SampathiraoPosted Jun 18, 2011, 1:23 AM
refer these links:
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/MasterDetailedDisplay11242005002621AM/MasterDetailedDisplay.aspx
http://www.c-sharpcorner.com/UploadFile/avi_sanjay/NestedRepeater.htm06012006143302PM/NestedRepeater.htm.aspx
http://www.dotnetspider.com/resources/744-Using-Nested-Repeater-Controls.aspx
http://www.codeproject.com/KB/aspnet/AspNetNestedRepeaters.aspx
http://idunno.org/archive/2004/10/30/145.aspx
http://support.microsoft.com/kb/306154
Hope it resolve ur problem...