I did a workaround by creating a property in the page:
protected bool IsEditMode
{
get { return this.EditMode; }
set { this.EditMode = value; }
}
Then in the GridView I have the controls for view and edit mode inside an item template. Setting the visibility based on the property value:
<asp:TemplateField SortExpression="Status" HeaderText="Status">
<ItemTemplate>
<asp:Label Id="lblStatus" Text='<%# Eval("Status") %>' Visible='<%# !IsEditMode %>' runat="server" />
<asp:TextBox ID="txtStatus" Text='<%# Eval("Status") %>' Visible='<%# IsEditMode %>' runat="server" />
</ItemTemplate>
This works for editing the whole gridview. You'll probably need to make a few modifications to make it work for individual rows.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…