我有一个绑定到 ObjectDataSource 的 FormView。
* ObjectDataSource 定义(为简单起见省略了部分)*
<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 定义(为简单起见,省略部分)*
<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>
我想知道:当单击更新按钮时,FormView 如何知道要使用哪个 EditTemplate TextBox 填充哪个 UpdateParameter?
例如,我没有在 FormView 中指示“txtAddress”填充 UpdateParameter“sAddress”,但 InputParameters[“sAddress”] 包含 txtAddress 的文本值。它怎么知道这样做?
有哪位大师能开导我吗?
太感谢了,
卡伦