I know that someone is going to want code for this issue but the plumbing code for a Gridview, the Object Data Source and all its associated events, along with the wired up business objects is too much no matter how I could condense it. However I think the question can still be answered.
I have an ObjectDataSource associated with a ASP.NET Gridview and a default SelectMethod named GetALLNames. This method say brings back 100 records by default and binds them to the GridView.
However on this page I have a ‘Search’ button (outside the grid) where the user can pick a single name and press ‘Search’. The Search button changes the .SelectMethod to GetNameByID, returns the list, and binds the short filtered list to the Gridview. This works great too, as the GridView only has 1 record in it.
Now the issue, when I press the Edit button on this GridView to go into edit mode on the single record showing, the Object Data Source appears to be refetching ALL records from the default GetALLNames method via the cache (I have EnableCaching="True" on the ODS) . The result? The GridView does indeed go into edit mode, but for the 1st record out of the 100 original, and not into edit mode on the single filtered record.
Is there a way to prevent the ODS from refetching from that default list from the Cache or from calling the original GetALLNames method, and instead just go into Edit mode on the single record?
Thanks!
A similar problem had me stumped for a while. What finally clicked the light on for me was this statement:
In my case, the ODS object was relying on a property being set before the select method was called (i.e.
ODS.partNumber="123"followed byODS.getPart).To get the ODS to function correctly, I had to populate the object’s required properties in the associated GridView’s _RowEditing, _RowUpdating, and _RowCancellingEdit handlers. That way, when the ODS object was rebuilt upon clicking any of those buttons in the GridView, all of the required properties were set.
It might not apply exactly in the same way in your case, but it could be related.