我有一个formView并绑定这些事件:
<ItemTemplate>
<div dir="ltr">
<table>
<tr>
<td class="titleHead">Categury:</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="lst" Text='<%# Eval("ItemCat.Name") %>' runat="server"></asp:Label>
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="titleHead">Name :</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="txtName" Text='<%# Eval("Name") %>' Width="300px" runat="server"></asp:Label>
</td>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td class="titleHead">Description :</td>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="txtDescription" Text='<%# Eval("Description") %>' runat="server"></asp:Label>
</td>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td style="width: 150px;">
**<asp:ImageButton ID="btnEdit" ImageUrl="~" CommandName="Edit" runat="server" />**
<asp:ImageButton ID="btnDelete" ImageUrl="~" CommandName="Delete" runat="server" />
</td>
<td> </td>
</tr>
</table>
</div>
</ItemTemplate>
<EditItemTemplate>
<div dir="ltr">
<table>
<tr>
<td class="style1">Categury:</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:DropDownList ID="lstCats" DataValueField="Id" DataTextField="Name" ValidationGroup="vgrpEditfrm" runat="server"></asp:DropDownList>
</td>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Name :</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtName" Text="" Width="300px" ValidationGroup="vgrpEditfrm" runat="server" ></asp:TextBox>
</td>
<td> </td>
<td>
<asp:RequiredFieldValidator ID="rqValidator" ControlToValidate="txtName" ForeColor="Red"
ValidationGroup="vgrpEditfrm" runat="server">*</asp:RequiredFieldValidator> </td>
<td> </td>
</tr>
<tr>
<td>Display Name :</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<cke:CKEditorControl ID="txtDisplayName" Text="" Toolbar="Source |Bold|Italic|Underline|Strike|SpecialChar|-|JustifyLeft|JustifyCenter|JustifyRight|JustifyBlock|BidiLtr|BidiRtl|-|Subscript|Superscript|NumberedList|BulletedList|-|Outdent|Indent/Styles|Format|Font|FontSize|TextColor|BGColor|Link|" Height="40px" BasePath="~/Resource/ckeditor" ValidationGroup="vgrpEditfrm" runat="server"></cke:CKEditorControl>
</td>
<td> </td>
<td>
</td>
<td> </td>
</tr>
<tr>
<td>Descritpion :</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<cke:CKEditorControl ID="txtDescription" Text="" Toolbar="Full" BasePath="~/Resource/ckeditor" Height="1000px" ValidationGroup="vgrpEditfrm" runat="server" />
</td>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td style="width: 150px;">
<asp:ImageButton ID="btnUpdate" CommandName="Update" ImageUrl="" CausesValidation="true" ValidationGroup="vgrpEditfrm" runat="server" />
<asp:ImageButton ID="btnCancel" CommandName="Cancel" ImageUrl="" ValidationGroup="vgrpEditfrm" runat="server" />
</td>
<td> </td>
</tr>
</table>
</div>
</EditItemTemplate>
和
void frm_ModeChanging(object sender, FormViewModeEventArgs e)
{
lblResult.Text += "changing...";
//here my currunrformviw state is readonly
Frm.ChangeMode(FormViewMode.Edit);
//now mode is Edit
}
void frm_ModeChanged(object sender, EventArgs e)
{
// this method doesn't raised and FormView is In Readonly Mode
lblResult.Text += "changed...";
}
当我点击编辑按钮改变凸起但改变了而不是rasid
更新: 实际上我想在readonly模式下点击编辑按钮,它进入编辑模式。