By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,683 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,683 IT Pros & Developers. It's quick & easy.

Formview inside of a User Control

P: n/a
I have created a usercontrol (ascx file) which contains a formview, inside
of the formview I have an EditItemTemplate and an ItemTemplate. Both the
EditItemTemplate and ItemTemplate have link buttons which call some code to
changed the formview mode from Edit to ReadOnly or vice versa. When I run
the code though and click the link buttons, the formview doesn't switch
modes (the page reloads the mode just doesn't change)

Here is the code which switches modes:

protected void view_linkbutton_click(object sender, EventArgs e)
{
formview.ChangeMode(FormViewMode.ReadOnly);
}

protected void edit_linkbutton_click(object sender, EventArgs e)
{
formview.ChangeMode(FormViewMode.Edit);
}

Here is an excerpt of the formview:

<asp:FormView ID="formview" runat="server"
DataSourceID="formview_datasource" Width="100%" DefaultMode="ReadOnly">
<EditItemTemplate>
<table>
<tdMode:</td>
<td><asp:LinkButton ID="ViewLinkButton" runat="server"
OnClick="view_linkbutton_click">View</asp:LinkButton>
|
<asp:LinkButton ID="EditLinkButton" runat="server"
OnClick="edit_linkbutton_click">Edit</asp:LinkButton></td>
</EditItemTemplate>
<ItemTemplate>
<table>
<tdMode:</td>
<td><asp:LinkButton ID="ViewLinkButton" runat="server"
OnClick="view_linkbutton_click">View</asp:LinkButton>
|
<asp:LinkButton ID="EditLinkButton" runat="server"
OnClick="edit_linkbutton_click">Edit</asp:LinkButton></td>
</ItemTemplate>

This code previously worked before I moved it from default.aspx to a user
control (ascx) file. So I can't seem to figure out why its stopped working.
Do I need to reference the formview differently now that I moved it to the
ascx file?

Thanks
Brad
Jun 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Alright - i'm just a moron. I had a simple typo in some related code (not
above) which was causing the problem. Thank you for anyone that looked at
this :)

Brad

"Brad Baker" <br**@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I have created a usercontrol (ascx file) which contains a formview, inside
of the formview I have an EditItemTemplate and an ItemTemplate. Both the
EditItemTemplate and ItemTemplate have link buttons which call some code to
changed the formview mode from Edit to ReadOnly or vice versa. When I run
the code though and click the link buttons, the formview doesn't switch
modes (the page reloads the mode just doesn't change)

Here is the code which switches modes:

protected void view_linkbutton_click(object sender, EventArgs e)
{
formview.ChangeMode(FormViewMode.ReadOnly);
}

protected void edit_linkbutton_click(object sender, EventArgs e)
{
formview.ChangeMode(FormViewMode.Edit);
}

Here is an excerpt of the formview:

<asp:FormView ID="formview" runat="server"
DataSourceID="formview_datasource" Width="100%" DefaultMode="ReadOnly">
<EditItemTemplate>
<table>
<tdMode:</td>
<td><asp:LinkButton ID="ViewLinkButton" runat="server"
OnClick="view_linkbutton_click">View</asp:LinkButton>
|
<asp:LinkButton ID="EditLinkButton" runat="server"
OnClick="edit_linkbutton_click">Edit</asp:LinkButton></td>
</EditItemTemplate>
<ItemTemplate>
<table>
<tdMode:</td>
<td><asp:LinkButton ID="ViewLinkButton" runat="server"
OnClick="view_linkbutton_click">View</asp:LinkButton>
|
<asp:LinkButton ID="EditLinkButton" runat="server"
OnClick="edit_linkbutton_click">Edit</asp:LinkButton></td>
</ItemTemplate>

This code previously worked before I moved it from default.aspx to a user
control (ascx) file. So I can't seem to figure out why its stopped
working. Do I need to reference the formview differently now that I moved
it to the ascx file?

Thanks
Brad

Jun 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.