GridView FormView not in sync


Q. John Chen

I have a GridView and a FormView serve as master/detail relation.
The GridView has paging enabled - 10 rows/page.

The formView is linked to gridView's SelectedValue as the sole

All works well, for example:

1. Select the first row in GridView; The FormView shows the detail
correspond to the first record.
2. Select another page, the same row (number) is automatically
selected; The formView shows the correct info.

BUT, there is one exception:
1. Select the last row in first page; The FormView is good.
2. Select the last PAGE (which only has 5 rows); No row is selected and
FormView shows nothing.
3. I then select the previous page. The last row IS SELECTED in

I tried to look at the values in the code (PageIndexChanged Event). The
SelectValue of the gridview is not even set yet (null) and the
SelectedIndex is always 9 (the last row).

Any explaination? How can I fix this? All I care is master and detail
are in sync. I also tried to just simple change the SelectedIndex to
the lastRow if totol rows are less than 10 but what property can be
used to determine this?




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