I am using ImageButtons in place of LinkButtons in a FormView to issue New/Edit/Delete/Cancel commands, but they don't seem to have an effect on the FormView.
The ImageButtons will cause a postback but the FormView mode doesn't change from the current mode.
I'm sure the ImageButtons were working at one point, but I've been busy with other pages for a while. The only thing that's changed between now and then are some patches I installed in Visual Studio.
I haven't been able to find any information related to this issue other than this: http://www.codeproject.com/KB/webforms/TamingTheFormView.aspx In that article there's an onclick method for an ImageButton that's used to change the FormView mode.
Would that be the only way to use ImageButtons instead of LinkButtons in a FormView?
Here are some code fragments:
<asp:FormView ID="CourseFormView" runat="server" DataKeyNames="CourseCode"
DataSourceID="CourseSqlDataSource" ondatabound="CourseFormView_DataBound">
<ItemTemplate>
<table>...</table>
<asp:ImageButton ID="EditCourseImageButton" CssClass="image_button"
runat="server" CommandName="Edit"
ImageUrl="~/images/icons/pencil.png" />
</ItemTemplate>
</asp:FormView>
Codebehind:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["code"] == null ||
Request.QueryString["code"] == "")
{
CourseFormView.ChangeMode(FormViewMode.Insert);
CourseCodeTitleLabel.Visible = false;
CourseTitleTitleLabel.Text = "Add a new course...";
SchedulePanel.Visible = false;
}
}
There is no other code for processing the buttons. I had created some empty event handlers for the FormView to see what was happening - ModeChanging, ModeChanged, and ItemCommand. None of them were being called when I clicked on the ImageButton, but everything worked fine if I used a LinkButton.
I'm not doing anything complicated - I just want the FormView to respond to basic ImageButton commands.