Solved

GridView RowCommand Pagechanged

Posted on 2007-11-28
5
2,180 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
  • 4
5 Comments
 
LVL 11

Accepted Solution

by:
cmhunty earned 500 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now