FormView out of sync

F

flodpanter

I have one objectdatasource which both a gridview and a formview rely
on.

In my Gridview I have a command button which should display the
selected row in my formview.

Sorting the gridview doesnt effect the formview. The formview still
uses the original order by which my records are stored. How can solve
this?
 
C

Cowboy \(Gregory A. Beamer\)

It should be working with the DataKeyName(s) without issue, as long as you
set the DataKeyName(s). If this is not working, there are a couple of ways
to "fake" this. One is to add a button column (can be a link button rather
than a true button) and tack an ID to the event args. Thsi is a bit more
programming, but ties to data instead of row position. Anotehr is to have a
postback via a hyperlink column. The downside here is info coming up on the
querystring (not a problem in most applications, but it can have
consequences in others, esp. if the grid still has to show (as viewstate is
cleared with a GET)). As long as you do not have to display both Grid and
form at the same time, however, this works. If you have to reconstitute the
grid exactly as left, you will have to store some pointers in session or
cache to restore when you pull data on the next hit.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
F

flodpanter

I have set the DatakeyNames in both GV and FV to the same id value.
Do I have to do further coding in the Gridviews sorted event to make it
work?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top