Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. PagedDataSource Unlimited size

PagedDataSource Unlimited size

Scheduled Pinned Locked Moved ASP.NET
helpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Senseicads
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • S Senseicads

      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

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Why don't you just turn paging off. That should do it. Ben

      S 1 Reply Last reply
      0
      • K kubben

        Why don't you just turn paging off. That should do it. Ben

        S Offline
        S Offline
        Senseicads
        wrote on last edited by
        #3

        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 have Protected 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

        K 1 Reply Last reply
        0
        • S Senseicads

          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 have Protected 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

          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          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 If

          When the dropdown event happens the pageload method is called again. Hope that helps. Ben

          S 1 Reply Last reply
          0
          • K kubben

            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 If

            When the dropdown event happens the pageload method is called again. Hope that helps. Ben

            S Offline
            S Offline
            Senseicads
            wrote on last edited by
            #5

            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

            K 1 Reply Last reply
            0
            • S Senseicads

              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

              K Offline
              K Offline
              kubben
              wrote on last edited by
              #6

              Glad it worked for you. Sometimes it just helps to bounce a question off someone else. Ben

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups