Home All Groups Group Topic Archive Search About

bug with gridview.selectedvalue?

Author
10 Mar 2006 5:49 PM
Trapulo
I'have a gridview that shows a list of item. Then, on same page, I have a
detailsview that may show full details for items selected on main gridview.

So I defined two objectDataSources: one that retrieves all items, and
provides them to gridview, and an other that returns only one item. This
latter requires am input parameter (ID of item to show), that it retrieves
from gridview.SelectedValue property.
All object have enableViewState=false.

It seems that nothing works until I read selectedValue property value from
my codeBehind code (or either from immediate window in VS 2005):

Protected Sub gwItems_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles gwItems.SelectedIndexChanged
Dim a As Object = gwItems.SelectedValue

End Sub

Without this code, detailsView doesn't show anything. With this code, all
works.
Is this a bug of datagrid? Is this the right way to create this kind of
page?

thanks

Author
13 Mar 2006 6:42 AM
Steven Cheng[MSFT]
Hi Trapulo,

Thanks for your posting.

Regarding on the GridView.SelectedValue issue, is it occuring specific to a
certain page, or specific to the "enableViewState=false"?  Also, you can
try checking the "SelectedIndex" property of the GridView control to see
whether it stores the correctly value. 

Based on my local test( I use two SqlDataSource controls instead, and
Gridview + DetailsView, with page's viewstate disabled), seems it can work
correctly.(When I change the GridView's selectedItem, the DetailsView will
display the columns for that  corresponding selected item in GridView. If
you feel necessary, I can paste my test page's code.

Please feel free to let me know if there's anything I missed.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)