How are FormView EditTemplate update values ​​updated in ObjectDataSource UpdateParameters under the hood?

I have a FormView attached to an ObjectDataSource.

* Definition of ObjectDataSource (missing part for simplicity) *

<asp:ObjectDataSource 
    ID="odsHousehold" 
    runat="server"
    TypeName="BLL.Households"
    ConflictDetection="OverwriteChanges"
    UpdateMethod="UpdateHousehold" 
    >
    <UpdateParameters>
        <asp:Parameter Name="sName" Type="String" Direction="Input" />
        <asp:Parameter Name="sAddress" Type="String" Direction="Input" DefaultValue="" />
        <asp:Parameter Name="sCity" Type="String" Direction="Input" DefaultValue="" />
        <asp:Parameter Name="sState" Type="String" Direction="Input" DefaultValue="" />
        <asp:Parameter Name="sZip" Type="String" Direction="Input" DefaultValue="" />
    </UpdateParameters>
</asp:ObjectDataSource>

* FormView definition (missing part for simplicity) *

   <asp:FormView 
    ID="fvHousehold"
    runat="server"
    DataKeyNames="HouseholdID"
    DataSourceID="odsHousehold"
    HorizontalAlign = "Left"
 >
<EditItemTemplate>
<asp:TextBox ID="txtHouseHoldName" runat="server" MaxLength="50" Width="100%" Text='<%# Bind("HouseholdName") %>'></asp:TextBox>
<asp:TextBox ID="txtAddress" runat="server" MaxLength="50" Width="100%" Text='<%# Bind("Address") %>'></asp:TextBox>
<asp:TextBox ID="txtCity" runat="server" MaxLength="50" Width="100%" Text='<%# Bind("City") %>'></asp:TextBox>
<asp:TextBox ID="txtState" runat="server" MaxLength="50" Width="100%" Text='<%# Bind("State") %>'></asp:TextBox>
<asp:TextBox ID="txtZip" runat="server" MaxLength="50" Width="100%" Text='<%# Bind("Zip") %>'></asp:TextBox>
 <asp:Button ID="btnUpdateHousehold" runat="server" Text="Update" CommandName="Update" />
</EditItemTemplate>
</asp:FormView>

I would like to know: how does FormView know which UpdateParameter to fill in, with which EditTemplate TextBox when I click the Update button?
For example, I did not instruct "txtAddress" in FormView to populate the "sAddress" UpdateParameter parameter, but InputParameters ["sAddress"] contains the text value txtAddress. How does he know that?

Can any guru enlighten me?

Thank you very much,

Cullen

+5
3

", FormView , UpdateParameter , EditTemplate TextBox " "?

, : - Bind, TextBox. . txtAddress "Bind" ( "" ), , , txtAddress ""

+2

, , TextBox EditItemTemplate? UpdateParameters...

txtHouseHoldName txtAddress, sName ?

+1

I have a blog post with a detailed discussion of how Bind () works at http://www.aarongoldenthal.com/post/2009/03/15/ASPNET-Databinding-Bind()-Method-Dissected.aspx .

+1
source

All Articles