FormView and Master Page

Discussion in 'ASP .Net Web Controls' started by Baffled, Nov 12, 2009.

  1. Baffled

    Baffled Guest

    Hi,

    I have a master page where I am Editing the data in a FormView. What I am
    trying to do is setup a common interface to do this so that all of my pages
    edit the data in the same mannor. I am placing the FormView on the Master
    page and placing a ContentPlaceHolder within the ItemTemplates so that I can
    setup the fields specific to each of the child pages. The problem I am
    having is that when the user clicks the Update button value list from the
    bound fields has no values in it and thus the DataSource can not perform the
    update. I have found that if I do not use the ContentPlaceHolder and place a
    FormView on each child page things work correctly.

    Here is an example of the markup from my master page:

    <asp:FormView ID="fvDetailRecord" runat="server" DataSourceID="dsDetails"
    DefaultMode="Edit"
    Width="100%" OnItemUpdating="fvDetailRecord_ItemUpdating">
    <EditItemTemplate>
    <table border="0" cellpadding="3" cellspacing="0" width="100%">
    <asp:ContentPlaceHolder ID="EditTmplt" runat="server">
    </asp:ContentPlaceHolder>
    </table>
    <asp:LinkButton ID="UpdateButton" runat="server"
    CausesValidation="True" CommandName="Update"
    Text="Update" />

    <asp:LinkButton ID="UpdateCancelButton" runat="server"
    CausesValidation="False"
    CommandName="Cancel" Text="Cancel" />
    </EditItemTemplate>
    <InsertItemTemplate>
    <table border="0" cellpadding="3" cellspacing="0" width="100%">
    <asp:ContentPlaceHolder ID="InsertTmplt" runat="server">
    </asp:ContentPlaceHolder>
    </table>
    <asp:LinkButton ID="InsertButton" runat="server"
    CausesValidation="True" CommandName="Insert"
    Text="Insert" />

    <asp:LinkButton ID="InsertCancelButton" runat="server"
    CausesValidation="False"
    CommandName="Cancel" Text="Cancel" />
    </InsertItemTemplate>
    <ItemTemplate>
    Read Only
    </ItemTemplate>
    </asp:FormView>


    And here is an example of markup from a child page:
    <asp:Content ID="Content7" ContentPlaceHolderID="EditTmplt" runat="Server">
    <tr>
    <td>
    Branch:
    </td>
    <td>
    <asp:DropDownList ID="edtBranch" DataSourceID="odsBranch"
    runat="server" DataTextField="BranchName"
    DataValueField="BranchGuid"
    SelectedValue='<%# Bind("BranchId") %>'>
    </asp:DropDownList>
    </td>
    </tr>
    </asp:Content>
    <asp:Content ID="Content7" ContentPlaceHolderID="InsertTmplt" runat="Server">
    <tr>
    <td>
    Branch:
    </td>
    <td>
    <asp:DropDownList ID="edtBranch" DataSourceID="odsBranch"
    runat="server" DataTextField="BranchName"
    DataValueField="BranchGuid"
    SelectedValue='<%# Bind("BranchId") %>'>
    </asp:DropDownList>
    </td>
    </tr>
    </asp:Content>


    If I add code to the fvDetailRecord_ItemUpdating event that is something
    like this:

    protected void fvDetailRecord_ItemUpdating(object sender,
    FormViewUpdateEventArgs e)
    {
    int Cnt = e.NewValues.Count;
    }

    Cnt will always be zero. The information from the bound fields will never
    be passed.

    Any help would be very much appreciated.
    Baffled, Nov 12, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    Replies:
    1
    Views:
    993
    William Brogden
    Aug 5, 2004
  2. Zeba
    Replies:
    1
    Views:
    480
    Mark Rae
    Feb 22, 2007
  3. Baffled

    FormView and Master Page

    Baffled, Nov 16, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    581
    Baffled
    Nov 16, 2009
  4. Nathan Sokalski
    Replies:
    25
    Views:
    1,410
    Nathan Sokalski
    Mar 4, 2010
  5. SerpentKiss2010
    Replies:
    0
    Views:
    2,470
    SerpentKiss2010
    Apr 6, 2011
Loading...

Share This Page