Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GridView RowCommand Pagechanged

Posted on 2007-11-28
5
Medium Priority
?
2,188 Views
Last Modified: 2013-11-07
I have a griidview control.  When the user changes the selected row on the gridview I change a formview to display the information as well (allowing the user to edit the row via a formview).  I do this in the rowcommand event of the gridview.  Linking the formview to the gridview row by e.CommandArgument in the rowcommand event.  I needed to do it like this so it picked up the newly changed row.  

Now when I have my gridview do paging, it has the commandargument as the rowvalue of the dataset as opposed to the rowvalue of the displayed grid.  so then it fails when i try to get the row from the grid.

Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = gvSample.Rows(index)

For example: For a test I set the rows per page to be 2.  My total rows are 3.  So when i am on page 1 no problem at all.  When I go to page 2 I get an error.  When i print out the value of index it is 2.  

It then throws an error since there is only 1 row on that gridview page, when I try to Dim Row above.

Any ideas here?
0
Comment
Question by:Fraser_Admin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 11

Accepted Solution

by:
cmhunty earned 1500 total points
ID: 20365543
Not a very tidy way but would think it would work - can you not use this?


Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim currentIndex As Integer = index - (gvSample.PageIndex * intItemsPerPage)
Dim row As GridViewRow = gvSample.Rows(current)

Open in new window

0
 

Author Comment

by:Fraser_Admin
ID: 20367438
there is no build in functionality which allows you to get the current row on the current page?
0
 

Author Comment

by:Fraser_Admin
ID: 20367507
in the rowcommand event it uses the old value.  so if page 1 is display and then i click on page 2 it is firing the rowcommand event and the pageindex = 0, when really it should be 1.  so i guess that won't work.

is there anyways to have in there if the rowcommand event is fired due to a page break then skip it or something?
0
 

Author Comment

by:Fraser_Admin
ID: 20367510
oops i mean due to a page change not a page break.
0
 

Author Comment

by:Fraser_Admin
ID: 20403568
any ideas here?  
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question