I have FormView:
<asp:FormView ID="fvReport" runat="server" DefaultMode="ReadOnly" AllowPaging="false" OnModeChanging="fvReport_ModeChanging" DataKeyNames="id">
protected void fvReport_ModeChanging(Object sender, FormViewModeEventArgs e)
{
switch (e.NewMode)
{
case FormViewMode.Edit:
fvReport.AllowPaging = false;
break;
}
}
in ItemTamplate I put LinkButton:
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="true" CommandName="Edit" CommandArgument='<%# Eval("id") %>'>Редактировать</asp:LinkButton>
Of course, FormView has EditItemTemplate section.
When I click Button, FormView is refreshed and stays in ReadOnly. What am I doing wrong?
you have to call ChangeMode method of FormView and pass the mode
fvReport.ChangeMode(DetailsViewMode.Edit);