我試圖將事件中的EditItemTemplate綁定到的數據的值。 ListView ID是lvProducts,我如何在UpdateButton_Click方法中引用項目的數據?在單擊事件中獲取ListView綁定數據ASP.NET
這是編輯項模板:
<EditItemTemplate>
<tr>
<td class="narrow"><asp:Label runat="server" Text='<%#Bind("ProductID")%>' ID="idLabel"></asp:Label></td>
<td class="wide"><asp:Textbox runat="server" Text='<%#Bind("ProductTitle")%>' ID="nameEdit"></asp:Textbox><span style="color:red">*</span></td>
<td class="narrow"><asp:Textbox runat="server" Text='<%#Bind("StockAmount")%>' TextMode="Number" ID="Label4"></asp:Textbox></td>
<td class="narrow"><asp:Label runat="server" Text='<%#Bind("AvailableAmount")%>' ID="faxEdit"></asp:Label></td>
<td class="narrow"><asp:Checkbox runat="server" Checked='<%#Bind("ProductStatus")%>' Enabled="true" ID="Label6"></asp:Checkbox></td>
<td class="wide" style="text-align:center;"> <asp:LinkButton ID="UpdateButton" ToolTip='<%#Eval("ProductID")%>' OnClick="UpdateButton_Click" runat="server" CommandName="Update" Text="Save" />
<asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
</tr>
</EditItemTemplate>
C#:
protected void UpdateButton_Click(object sender, EventArgs e)
{
???
}
謝謝,只是一個評論:我改下聯:ListViewDataItem LVD = lvProducts.Items [I] – Yoav