PagedDataSource Unlimited size
-
Hi I am after a bit of help, I have a paged datasource displayed in a repeater which is working fine for me. The number of rows returned is populated from a ddl and is either 10, 20 or 50. This works ace and is brill. However I want to have another option for all. In which case all the rows are returned and only one page is shown. I have currently got the pagesize set to 2000000 which is not exactly ideal is it? Would like it so that it will just show them all rather than restricting to a page size no matter how large a one that I pick. Is there any ideas? Cheers Ian
-
Hi I am after a bit of help, I have a paged datasource displayed in a repeater which is working fine for me. The number of rows returned is populated from a ddl and is either 10, 20 or 50. This works ace and is brill. However I want to have another option for all. In which case all the rows are returned and only one page is shown. I have currently got the pagesize set to 2000000 which is not exactly ideal is it? Would like it so that it will just show them all rather than restricting to a page size no matter how large a one that I pick. Is there any ideas? Cheers Ian
-
Good plan although I am not sure how I can do this using my code. I mean I know its possible but just having a mental block, been looking at it for ages now and all the words are jumbling into one! ;) I have a load data method which populates my repeater.
' This Method is responsible for reloading the data when a user event like a sort or ' a filter is applied to the user control Private Sub LoadData(ByVal b As Boolean) 'I need to load all my data into the repeater control. Dim strConnectionString As String = sqlViewCalls.ConnectionString Dim sqlConnection As SqlConnection = New SqlConnection(strConnectionString) sqlConnection.Open() Dim sqlDA As SqlDataAdapter sqlDA = New SqlDataAdapter(hidViewString.Value.ToString() & hidQueryString.Value.ToString() & hidSortString.Value.ToString(), sqlConnection) Dim dt As DataTable dt = New DataTable() sqlDA.Fill(dt) sqlConnection.Close() ' Create a new PagedDataSource Dim pgItems As PagedDataSource pgItems = New PagedDataSource() ' Create a new DataView from the datatable we created before. Dim dv As DataView = New DataView(dt) ' Initialise the PagedDataSource and populate it. pgItems.DataSource = dv pgItems.AllowPaging = True pgItems.PageSize = pgSize pgItems.CurrentPageIndex = PageNumber If b = True Then If pgItems.PageCount > 1 Then Dim pages As ArrayList = New ArrayList() For index As Integer = 0 To (pgItems.PageCount() - 1) pages.Add((index + 1).ToString()) Next hidLast.Value = (pages.Count() - 1).ToString() Else hidLast.Value = 0 End If End If lblPagination.Text = " Page: " & (pgItems.CurrentPageIndex + 1).ToString() & " of " & pgItems.PageCount & " (" & pgItems.DataSourceCount & " Records)" repResults.DataSource = pgItems repResults.DataBind() End Sub
Then in the selection Changed of the ddl (which is populated by 4 values, 10,20,50 and all) I haveProtected Sub ddlPageSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPageSize.SelectedIndexChanged If ddlPageSize.SelectedIndex = 3 Then pgSize = 2000000 PageNumber = 0 LoadData(True) ' Code t
-
Good plan although I am not sure how I can do this using my code. I mean I know its possible but just having a mental block, been looking at it for ages now and all the words are jumbling into one! ;) I have a load data method which populates my repeater.
' This Method is responsible for reloading the data when a user event like a sort or ' a filter is applied to the user control Private Sub LoadData(ByVal b As Boolean) 'I need to load all my data into the repeater control. Dim strConnectionString As String = sqlViewCalls.ConnectionString Dim sqlConnection As SqlConnection = New SqlConnection(strConnectionString) sqlConnection.Open() Dim sqlDA As SqlDataAdapter sqlDA = New SqlDataAdapter(hidViewString.Value.ToString() & hidQueryString.Value.ToString() & hidSortString.Value.ToString(), sqlConnection) Dim dt As DataTable dt = New DataTable() sqlDA.Fill(dt) sqlConnection.Close() ' Create a new PagedDataSource Dim pgItems As PagedDataSource pgItems = New PagedDataSource() ' Create a new DataView from the datatable we created before. Dim dv As DataView = New DataView(dt) ' Initialise the PagedDataSource and populate it. pgItems.DataSource = dv pgItems.AllowPaging = True pgItems.PageSize = pgSize pgItems.CurrentPageIndex = PageNumber If b = True Then If pgItems.PageCount > 1 Then Dim pages As ArrayList = New ArrayList() For index As Integer = 0 To (pgItems.PageCount() - 1) pages.Add((index + 1).ToString()) Next hidLast.Value = (pages.Count() - 1).ToString() Else hidLast.Value = 0 End If End If lblPagination.Text = " Page: " & (pgItems.CurrentPageIndex + 1).ToString() & " of " & pgItems.PageCount & " (" & pgItems.DataSourceCount & " Records)" repResults.DataSource = pgItems repResults.DataBind() End Sub
Then in the selection Changed of the ddl (which is populated by 4 values, 10,20,50 and all) I haveProtected Sub ddlPageSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPageSize.SelectedIndexChanged If ddlPageSize.SelectedIndex = 3 Then pgSize = 2000000 PageNumber = 0 LoadData(True) ' Code t
In your load event I would check the dropdown index So add some code like:
pgItems.DataSource = dv
If ddlPageSize.SelectedIndex = 3 Then
pgItems.AllowPaging = False
Else
pgItems.AllowPaging = True
pgItems.PageSize = pgSize
End IfWhen the dropdown event happens the pageload method is called again. Hope that helps. Ben
-
In your load event I would check the dropdown index So add some code like:
pgItems.DataSource = dv
If ddlPageSize.SelectedIndex = 3 Then
pgItems.AllowPaging = False
Else
pgItems.AllowPaging = True
pgItems.PageSize = pgSize
End IfWhen the dropdown event happens the pageload method is called again. Hope that helps. Ben
Thanks for your help, That works great and is so obvious I can't believe I didn't think of it myself. Sometimes you can't see the wood for the trees can you? :D lol Cheers Ian
-
Thanks for your help, That works great and is so obvious I can't believe I didn't think of it myself. Sometimes you can't see the wood for the trees can you? :D lol Cheers Ian