2
我想將對象綁定到表單視圖。通過formview綁定和更新對象
<asp:FormView ID="formview" runat="server" DefaultMode="Edit" OnItemUpdating="formview_ItemUpdating">
<EditItemTemplate>
<ol>
<li>
<label class="leftCo">First</label>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("First")%>'></asp:TextBox>
</li>
<li>
<label class="leftCo">Second</label>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Second")%>'></asp:TextBox>
</li>
</ol>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
</EditItemTemplate>
</asp:FormView>
var objects = new List<OB> { new OB { First = "1111", Second = "2222" } };
formview.DataSource = objects;
formview.DataBind();
現在,是否有可能在更新時生成一個新對象,而無需使用findcontrol讀取每個文本框?
當我點擊更新按鈕時,我想用更新後的值創建OB對象,並且可以說將它傳遞給某個方法(在更新事件中)。
能否請你對你的問題的更詳細? – Nirmal 2011-03-02 09:02:43
看到我的更新,如果你想要的東西只是問。 – markizik 2011-03-02 09:08:16