Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Gridview button field only works on page 1 of grid

Reply
Thread Tools

Gridview button field only works on page 1 of grid

 
 
Julia B
Guest
Posts: n/a
 
      03-09-2010
Hi all

I've got a gridview in a Visual Studio 2005, .NET version 2.0 web app, which
displays many records. The grid's AllowPaging and AllowSorting properties are
set to true with the grid displaying 10 records per page.

There is a buttonfield column in the gridview which fires the grid
rowcommand event as follows:

Dim index As Integer
Dim selectedRow As GridViewRow
Dim filePath As String
'find the serial number of the record and open its change history
index = Convert.ToInt32(e.CommandArgument)
selectedRow = Me.SearchGrid.Rows(index)
Dim serialNumber As String = selectedRow.Cells(3).Text
Response.Redirect("ChangeHistory.aspx?SN=" & serialNumber)

This supposedly opens another page in the application based on the record
selected. If the user does this on the first page of the grid (i.e. the first
10 records) this works fine. However if the user sorts the records or goes to
another page, when they click on the button field, the record that opens is
one from the first page of the grid. The sort and page change don't seem to
be recognised by the grid even though the user can see the change.

Any ideas on what I need to do?

Thanks
Julia
 
Reply With Quote
 
 
 
 
Julia B
Guest
Posts: n/a
 
      03-09-2010
Hi, problem solved. All I needed to do was rebind the grid during the grids
PageIndexChanging event and then set the pageindex to the new pageindex as
follows:

Me.SearchGrid.DataBind()
Me.SearchGrid.PageIndex = e.NewPageIndex

Julia

"Julia B" wrote:

> Hi all
>
> I've got a gridview in a Visual Studio 2005, .NET version 2.0 web app, which
> displays many records. The grid's AllowPaging and AllowSorting properties are
> set to true with the grid displaying 10 records per page.
>
> There is a buttonfield column in the gridview which fires the grid
> rowcommand event as follows:
>
> Dim index As Integer
> Dim selectedRow As GridViewRow
> Dim filePath As String
> 'find the serial number of the record and open its change history
> index = Convert.ToInt32(e.CommandArgument)
> selectedRow = Me.SearchGrid.Rows(index)
> Dim serialNumber As String = selectedRow.Cells(3).Text
> Response.Redirect("ChangeHistory.aspx?SN=" & serialNumber)
>
> This supposedly opens another page in the application based on the record
> selected. If the user does this on the first page of the grid (i.e. the first
> 10 records) this works fine. However if the user sorts the records or goes to
> another page, when they click on the button field, the record that opens is
> one from the first page of the grid. The sort and page change don't seem to
> be recognised by the grid even though the user can see the change.
>
> Any ideas on what I need to do?
>
> Thanks
> Julia

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview pressing Edit do not show any editable editbox in grid, while delete works fine qa4ever ASP .Net Web Controls 3 04-16-2008 10:29 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
OnTextChanged only works for first textbox in grid? notTold ASP .Net Datagrid Control 0 05-20-2004 03:44 PM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM
If value in name field in top row disable submit button until add button is pressed or field is cleared. Chuck Javascript 0 11-10-2003 02:23 AM



Advertisments