From: Don on
I have a GridView inside a FormView and cannot get it into editMode.
The FormView is bound to an ObjectDataSource. One of the fields
returned by the ObjectDataSource is a List which I bind to the
GridView. In the GridView I have a field bound to the items in this
list.

If I click edit at runtime with this setup I get an error message that
says: "The GridView 'gvActionRecords' fired event RowEditing which
wasn't handled".
So, I have to handle this RowEditing event. In the event handler I
set the GridView's EditIndex value to the NewEditIndex in the
GridViewEditEventArgs variable. Once I do this I can get into edit
mode but I'm always one postback behind. I click edit on the 1st row
and nothing happens. I click Edit on the second row and the first
rows goes into edit mode. And so on...

I've tried reBinding the FormView after I set the Index and it does
nothing. I never get into edit mode, not even one postback behind.
I cannot reBind just the DataGrid because I get a run time error:
"Databinding methods such as Eval(), XPath(), and Bind() can only be
used in the context of a databound control."

I found a posting that is very close to this problem. Their solution
is to create a private class variable and set it to the EditIndex
variable in the RowEditing event. Then, during page Render set the
GridView's EditIndex to this private variable. I did this but then I
never get into edit mode (not even one step behind).

Here is a link to that post:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_frm/thread/4a738593c506a359/5182c2fd489c9292?hl=en&lnk=st&q=onRowEditing+objectDataSource+mode#5182c2fd489c9292

This is what my page does, and the code is below.
The ObjectDataSource has a SelectMethod which calls getWorkorder and
returns a class called WorkOrder.
This WorkOrder class has a Property called Actions which is a strongly
typed List<T>. My GridView is bound to this property using this
statement DataSource='<%# Eval("Actions") %>' .

The list returned by the Actions property contains a class which has a
property called WorkorderActionID that I bind to a BoundColumn in the
DataGrid.

Here is the page:

<asp:ObjectDataSource ID="odsWorkorders" runat="server"
SelectMethod="getWorkorder"
TypeName="RIPData.WorkOrder.WorkOrders">
<SelectParameters>
<asp:Parameter Name="workorderNumber" Type="String" />
<asp:Parameter Name="tailNumber" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:FormView ID="FormView1" runat="server"
DataSourceID="odsWorkorders">
<ItemTemplate>
<table align="left">
<tr>
<td><asp:Label ID="Label2" runat="server" Text="Workorder
Number:" SkinID="label"></asp:Label></td>
</tr>
<tr>
<td>
<asp:GridView ID="gvActionRecords" runat="server"
ShowHeader=False
AutoGenerateColumns="False" CellPadding="4"
DataSource='<%# Eval("Actions") %>'
ForeColor="#333333" GridLines="None"
OnRowEditing="gvActionRecords_OnRowEditing">
<Columns>
<asp:BoundField DataField="WorkorderActionID" /
>
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>