I have a page, lets call it SourceTypes.aspx, that has a a GridView that is displaying a list of Source Types. Part of the GridView is a DataKey, SourceTypeID. If source TypeID is passed to the page via a query sting, how to I put the Gridview into Edit mode for the appropriate row based on the SourceTypeID?
The GridView is bound to a SQlDataSource object.
I have a feeling I am going to kick myself when the answer appears!!
I have looked at Putting a gridview row in edit mode programmatically but it is some what lacking in specifics
First of all, many thanks to Steve Robins for getting me started down the right track. My approach was slightly different, partial due to the fact I was not using a DataBind method.
I use a combination of the OnRowDataBound and OnDataBound events of the DataView. The OnRowDataBound event to determine the index of the row to be put into edit mode. The OnDataBound event sets the index and rebinds the DataView.
A variable is used to ensure that the View is not continuously rebound.
Here is the crux of the aspx page edited down for brevity.
And now for the code behind.
Hopefully between Steve and Myself we help a few of you out there