FormView and Master Page

B

Baffled

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top