Gridview button field only works on page 1 of grid

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
0
Utf
3/9/2010 3:19:01 PM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

1 Replies
712 Views

Similar Articles

[PageSpeed] 13

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
0
Utf
3/9/2010 4:09:01 PM
Reply:

Similar Artilces:

Using an imagebutton and gridview checkbox colunm
I have a gridview were I am using a colunm of checkboxes, if checked I can delete that row. My checkbox code: <asp:ImageButton Id="DeleteMsg" runat="server" ImageUrl="/image/Delete.gif" onclick="DeleteMsg_Click" /> and the event: protected void DeleteMsg_Click(object sender, ImageClickEventArgs e) { } But I keep getting and error: cs1061 "Does not contain a definition for DeletAll... What is wrong with my code? I have asked this same question in the asp.net Forum but help as of yet. How do I fix this?...

Custom POS buttons question
I would like to set up 10 custom buttons, but need help with the format. The first type I need is to be able to sell a certain item as an example the code 99595PE. Also what type of pictures can you have in the custom buttons do jpeg and gif's work? As for the 2nd type of button I need is a lot more complicated, I need a button that would make the current X report show on the screen. Our clerks end up printing out a lot of Xreports becuase they need to see if they need to do a cash drop or not through out the day. Any help would be appreciated. Look at RR RMS Utilities Store as we...

Go to Page 1
Hi! I have a main form with TabCtl with 10 pages. In this main form I have one combo to choose record. I woul like when click in combo oblige go to Page 1 of this record. Is it possible, please? Thanks in advance. an Hopefully this will help you. http://www.thescripts.com/forum/thread615446.html -- Hope this helps, Daniel P "an" wrote: > Hi! > > I have a main form with TabCtl with 10 pages. > In this main form I have one combo to choose record. > I woul like when click in combo oblige go to Page 1 of this record. > Is it possible, please? > Thanks ...

Properties button in Lookup: What is it used for?
Hello, Does someone know what is the use of the Properties button in a lookup window (lower left corner near the 'New' button)? On a mouse over it says 'View the selected record's properties'. Well, nothing happen when I press on it and a record is selected in the lookup. Many thanks! Claude R. It should open the record for you. This is so you can inspect the record to see if it is the one you want to lookup, without actually accepting it as the lookup record. Does that make sense? If it's not opening anything for you, then that would definitely seem strange....

does office 2007 work with windows 7
Ihave a new computer with and want to buy office home & student, will it work with windows 7 Yes -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "jackis" <jackis@discussions.microsoft.com> wrote in message news:AB60EF4E-C0E8-4955-9021-496F7924516A@microsoft.com... > Ihave a new computer with and want to buy office home & student, will it > work > with windows 7 ...

Working program now doesn't, can't activate workbook's worksheet to paste data
I have written a program which has automated some boring/ repetitive/ time consuming business processes.This program worked. I am now preparing documentation for this program with a co-worker. Today the program didn't work properly. After stepping through the code, I found that a column of numbers I was copying from Sheet "Suppliers with ABN_ACN_BN" in Book "Automation V005.xls" to Sheet "ABNLookup" in Book "ABNLookUp.xls" wasn't copying (even though it used to). Investigating this further (with another co-worker who knows VBA), we found (using t...

Copy Formula From 1 Workbook to Another
I copied a formula from one workbook to another. Worked great .. except that when I pasted the formula in the receiving cell, i referenced the source workbook. I don't want to do that ... I want t paste the raw formula, make a small change and recalc. My workaroun was to edit the links and change the source to my receiving workbook. That did it. My question > Is there an- easier- way to do this? ( i.e not have to edit the links ) -- Ceci ----------------------------------------------------------------------- Cecil's Profile: http://www.excelforum.com/member.php?action=getinfo&...

Access 2003
Hello, I have two different Access 2003 databases, one has a problem with showing options when the right mouse button is clicked on a table, query or anything, the other one does not. This started happening out of the blue ... I checked tools, options thinking I had inadvertly set some sort of option, but there is nothing that I can see that would affect the mouse in one data base and not the other .. very strange. It is the same on my computer at home and at the office ... Any help on this would be much appreciated. Abay Is there anything else running that could interfere? The ...

1.2 Integration is not really 1.2?
Found out today that MS labeled the 1.2 integration disk incorrectly. Although it says 1.2, it's really 1.0 integration. Thought I would throw that out there before someone else "pays" like I did for one of MANY Microsoft mess ups with CRM! I went ahead and upgraded to 2003 Server and CRM 1.2 only to find out that 1.2 integration won't release for several weeks or months. So now I sit and wait. I could have had this all installed on W2K server if MS would have been more clear on the whole thing (or been "normal" and released CRM and Integration 1.2 at the same t...

Forms / Command Button Help
Hi Does any one know when creating a form which requires you to click on an accept button to get into the spreadsheet how you make it so you can press ENTER on the keyborad to accept rather than having to click on accept with the mouse? Thanks Nick click on the button in your form, hit F4 to see its properties. Look for Default--set it for true. Look at VBA's help. And then look at the .cancel property for the "Cancel" button. You'll want that, too. Nick wrote: > > Hi > > Does any one know when creating a form which requires you > to click on an ...

The PivotTable field name is not valid (error)
Hey, wonder what I might do here. Using excel 2007 to link to a sharepoint "list". I then "pivot" this list for a variety of reports. However, when I then, say, the next day, choose Data, Fresh, and then go back to the pivot table and right click on it to refresh, and see change, I get an error: "The PivotTable field name is not valid. To create a PivotTable report, you must use data that is organized as a list with labeled columns. If you are changing the name of the PivotTable field, you must type a new name for the field." And of course, ...

Button to Activate Macro
I have recorded a simple macro to hide a few columns of an Excel spreadsheet. I would like to run the macro from a click event for a button control. I added the button from the control toolbox. When I right click on the control, "assign macro" is not one of my available choices. I can see no way to make the object perform the macro task. What am I missing here? Thanks Jon, Control toolbox buttons are event driven, so go into design mode (the triangle on the control toolbar) and double-click the button. You will then be presented with a skeletal procedure where you can add you...

OWA Mailboxes on different servers do not work
Hi All, I am running a Ex 2003 org and run OWA on a public facing machine. You are able to login to any user that has a mailbox on that machine, however when you try any user on another server it states "page cannot be displayed" . It looks like it is trying to resolve the other server's name publically. Any help would be appreciated. Thanks On Tue, 30 Nov 2004 11:55:04 -0800, "jbud" <jbud@discussions.microsoft.com> wrote: >Hi All, > >I am running a Ex 2003 org and run OWA on a public facing machine. You are >able to login to any user that ...

Number of pages in worksheet doesn't match Print Preview pages
I have a 16-page worksheet. When I try to print or go into print preview, it shows the document is 160 pages. Upon review, it looks like it's just printing 10 copies of the 16 page worksheet, but ONLY 1 COPY is chosen. This doesn't happen with any other file/worksheet, and can't find why on this one. On May 10, 4:12=A0pm, delru <de...@discussions.microsoft.com> wrote: > I have a 16-page worksheet. =A0When I try to print or go into print previ= ew, it > shows the document is 160 pages. =A0Upon review, it looks like it's just > printing 10 copies of ...

I need to renable autosum button
I set excel so that each column heading has drop down buttons enabling me to sort out entries (rows) by what is entered in any cell. Now my autosum button is disabled. I can still make formulas step by step. I don't remember how i set it up that way, or I'd just turn it off while trying to enter formulas..... TIA Flint wrote: > I set excel so that each column heading has drop down buttons enabling me to > sort out entries (rows) by what is entered in any cell. Now my autosum button > is disabled. I can still make formulas step by step. I don't remember how i > ...

Send Button #12
Setting up outlook for first time. Set up goes ok test button works and test mesage shows up in inbox. No send button when I open email. Erased profile set up again several times always same results. -- jayg Are you making a new profile using a new name for it? Don't delete it then use the same name for the next try. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlo...

Is there a Quicktime that works on Win98?
I went to a website that said you have to download some plug-in to view this video. Ok, I went to the website and it came up with 'free' Quicktime for WinXP, Vista, and Windows 7. I'll bet it's over 3 times the size of Quciktime that ran on Win98 [and I'll bet it crashes Win98], so where can I find Quicktime that runs on Win98? On 02/09/2010 01:35 PM, Robert Macy wrote: > I went to a website that said you have to download some plug-in to > view this video. > > Ok, I went to the website and it came up with 'free' Quicktime for > WinXP...

Pivot Table question: Creating a new field that calculates the division of one data field by another
I have a pivot table that includes the sum of sales (a data field) and the count of sales (a data field) by product. It looks like this. sum of sales Count of units Product a 100 8 product b 45 6 Etc. I am trying to create another field that divides the sum of sales by the count of units for each product (i.e. in a fourth column. Is there an easy way to do this (within the pivot table). I tried using the calculated field option, but didn't seem to find the way to do it. Also once I have created a c...

Arrow keys not moving 1 cell at a time
User has a spreadsheet where the arrow keys are doing a 'page down rather than moving 1 cell at a time. Not sure how this got set, or ho to get it back. Thanks for your help -- Message posted from http://www.ExcelForum.com slivi, check to see if scroll lock is on, on the key board -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 97 & 2000 ** remove news from my email address to reply by email ** "slivi >" <<slivi.11vnhp@e...

Onchecked_change in gridview
I've a grid view with a checkbox <asp:TemplateField HeaderText="Attiva" HeaderStyle-HorizontalAlign="Center"> <ItemTemplate> <div align="center"> <asp:CheckBox ID="chkAttiva" runat="server" Checked='<%# Eval("Attivta") %>' oncheckedchanged="chkAttiva_CheckedChanged" AutoPostBack="true"></asp:CheckBox> </div> </ItemTemplate> <I...

form button Report printing
Hi I have a button on a form that prints a report based on a query i do NOT show the report it just prints the report when the button is clicked however i would like a message box to show how many pages are needed to put in the printer to match the ammount of pages printing from the Report could anyone help me ASAP be most grateful... Ferrit04 wrote: >Hi I have a button on a form that prints a report based on a query i >do NOT show the report it just prints the report when the button is >clicked however i would like a message box to show how many pages are >needed to put in the ...

Vertic Printing Page Break ?
Hello: Always something new, I guess. This hasn't happened before; something changed, apparently. Have a single page with columns going from A thru F. Fairly narrow columns. Always printed easily on a single page. Now, when I go to Print Preview, I get the vertical dashed line on the extreme right of the page that I want to print, as it should be there. But, I also have a new vertical dashed line at column D. On Page Preview it shows that only up to this will be printed. And, it does actually only print out to Column D on a single page. Tried re-setting Print Area, etc., but nothin...

Report with buttons to open forms
Is it possible have a report which is from a query (which is based on numerous other queries) that has buttons to open a specific form for each record on the report? I would like users be able to open the report and select a button which opens a specific form based on the results shown on the report. Any suggestions would be appreciated. Thanks. -- Donna N. Donna, Reports don't support functional buttons, nor their events. Your best bet is to create a form that lists your records, and use a button on it , to call a form for a specific value. You should be ...

Grouping Fields
Within the coding of the form is there anyway of grouping fields under one name then preforming actions against that grouped name. For example, could you group fields called 'Name', 'Address', 'Telephone' under the name 'Personal' then do a visible action (through an IF statement) on the group called Personal? -- Cheers. Paul Pap wrote: >Within the coding of the form is there anyway of grouping fields under one >name then preforming actions against that grouped name. For example, could >you group fields called 'Name', 'Address...

styling in a gridview
I have a gridview that has a column that changes color onmouseover. But, I need to have the row return back to the original color in the onmouseout. The rows alternate backgroundcolor. Here is the code (_RowDataBound) that is currently in play; e.Row.Cells[4].Attributes.Add("onmouseover", "this.style.cursor='pointer'; this.style.backgroundColor='Gainsboro'; this.style.color='blue'"); e.Row.Cells[4].Attributes.Add("onmouseout", "this.style.color='black'"); I just added the Gains...