Reading all the rows of a datagrid that is using paging...

Discussion in 'ASP .Net Datagrid Control' started by Bob Morvay, May 3, 2005.

  1. Bob Morvay

    Bob Morvay Guest

    This should be simple but I am stuck. I am trying to read all the rows of
    my datagrid across all the pages. I can read all the rows on the page that
    I am on but I can't seem to figure out how to iterate through all the pages.
    Can anyone lend some insight. Here is the basic code that I am using to
    attempt to read all the rows...

    Private Sub btnUpdate(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnUpdate.Click
    Dim item As DataGridItem
    For Each item In DataGrid1.Items
    ID = Convert.ToInt32(DataGrid1.DataKeys(item.ItemIndex))
    UpdateTable()
    Next
    End Sub

    My example datagrid has 3 pages. This code will only update the database
    with the items on the page that I am on when I click the update button. I
    need it to iterate through all the pages of the datagrid for all the items.

    Thanks in advance.
    Bob Morvay, May 3, 2005
    #1
    1. Advertising

  2. Bob Morvay

    Bob Morvay Guest

    I figured it out. I had to set the currentpageindex of the datagrid, rebind
    my data and I can iterate through all the pages via the datagrid pagecount.

    "Bob Morvay" <> wrote in message
    news:O%23waeM$...
    > This should be simple but I am stuck. I am trying to read all the rows of
    > my datagrid across all the pages. I can read all the rows on the page
    > that I am on but I can't seem to figure out how to iterate through all the
    > pages. Can anyone lend some insight. Here is the basic code that I am
    > using to attempt to read all the rows...
    >
    > Private Sub btnUpdate(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnUpdate.Click
    > Dim item As DataGridItem
    > For Each item In DataGrid1.Items
    > ID = Convert.ToInt32(DataGrid1.DataKeys(item.ItemIndex))
    > UpdateTable()
    > Next
    > End Sub
    >
    > My example datagrid has 3 pages. This code will only update the database
    > with the items on the page that I am on when I click the update button. I
    > need it to iterate through all the pages of the datagrid for all the
    > items.
    >
    > Thanks in advance.
    >
    >
    >
    >
    Bob Morvay, May 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    1,610
  2. wh1974
    Replies:
    0
    Views:
    2,415
    wh1974
    Jan 12, 2005
  3. Red
    Replies:
    1
    Views:
    701
  4. Bob Morvay
    Replies:
    1
    Views:
    2,496
    Bob Morvay
    May 3, 2005
  5. Mattyw
    Replies:
    2
    Views:
    2,895
    Mattyw
    Sep 12, 2005
Loading...

Share This Page