【发布时间】:2011-08-15 14:26:16
【问题描述】:
作为我的问题Looping through a repeater control to get values of Textbox in asp.net的后续行动 如果用户在文本框中输入了一个数量,我想从转发器控件中获取相应的 ProductID 值:
<asp:Repeater ID="rptRequestForm" runat="server">
<HeaderTemplate>
<table border="0" width="100%">
<tr>
<td style="width:50%" class="TextFontBold"><asp:Label runat="server" ID="Label1" Text="Supply Name"></asp:Label></td>
<td style="width:25%" class="TextFontBold"><asp:Label runat="server" ID="Label2" Text="Quantity"></asp:Label></td>
<td style="width:25%" class="TextFontBold"><asp:Label runat="server" ID="Label3" Text="Price (ea.)"></asp:Label></td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" width="100%">
<tr>
<td style="width:50%" class="TextFont"><asp:Label ID="lblProductName" Text="<%#Trim(Eval("Product_Title"))%>" ><%#Trim(Eval("Supplie_title"))%></asp:Label></td>
<td style="width:25%"><asp:TextBox ID="txtBox" runat="server" Width="30%" onblur="Javascript:numberonly(this)"></asp:TextBox></td>
<td style="width:25%" class="TextFont"><span><%#Trim(FormatCurrency(Eval("Price")))%></span></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
我的代码隐藏是:
For Each item As RepeaterItem In rptRequestForm.Items
txtField = item.FindControl("txtBox")
If Not IsNothing(txtField) Then
j += 1
strText = strText & ", " & txtField.Text
End If
Next
我正在使用 FindControl 循环遍历文本框(查看用户是否输入了有效数量)。如何获取对应ProductID的值?
【问题讨论】: