Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Formview inside of a User Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brad Baker - 01 Jun 2007 20:56 GMT
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>
       <td> Mode:</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>
       <td> Mode:</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
Brad Baker - 01 Jun 2007 23:26 GMT
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

>I have created a usercontrol (ascx file) which contains a formview, inside
>of the formview I have an EditItemTemplate and an ItemTemplate. Both the
[quoted text clipped - 45 lines]
> Thanks
> Brad

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.