调用中继器内的按钮或下拉列表
我在repeater
内有一个label
和dropdownlist
。当我单击转发器外部的按钮时,我想访问 label.Text
值和 ddl.SelectedIndex
值。
<asp:Repeater ID="rptProduct" runat="server" DataSourceID="objdsProduct" OnItemCommand="rptProduct">
<ItemTemplate>
<div>
<div>
<asp:Label ID="lblProdName" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label>
</div>
<div>
<asp:DropDownList ID="ddlSize" runat="server" AutoPostBack="False" DataSourceID="objdsSize" DataTextField="SizeName" AppendDataBoundItems="True" DataValueField="SizeID">
<asp:ListItem Text="select a size" Value=0></asp:ListItem>
</asp:DropDownList>
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Button ID="btnChoose" runat="server" Text="Choose Products" />
有关如何访问 lblProdName.Text
和 ddlSize.SelectedValue
的任何建议:
Protected Sub btnChoose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChoose.Click
Dim ProductName
Dim Size
End Sub
感谢您的宝贵时间。
I have a label
and dropdownlist
inside a repeater
. When I click a button outside the repeater I would like to access the label.Text
value and ddl.SelectedIndex
value.
<asp:Repeater ID="rptProduct" runat="server" DataSourceID="objdsProduct" OnItemCommand="rptProduct">
<ItemTemplate>
<div>
<div>
<asp:Label ID="lblProdName" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label>
</div>
<div>
<asp:DropDownList ID="ddlSize" runat="server" AutoPostBack="False" DataSourceID="objdsSize" DataTextField="SizeName" AppendDataBoundItems="True" DataValueField="SizeID">
<asp:ListItem Text="select a size" Value=0></asp:ListItem>
</asp:DropDownList>
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Button ID="btnChoose" runat="server" Text="Choose Products" />
Any suggestions how I can access lblProdName.Text
and ddlSize.SelectedValue
within:
Protected Sub btnChoose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChoose.Click
Dim ProductName
Dim Size
End Sub
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其添加到您的按钮点击中:
Add this to your button click:
但是...您如何确定要从中获取值的中继器中的哪个项目?
查看此 MSDN 页面,特别是这一点:
But ... how are you going to identify which item in the repeater you want to get the values from?
Have a look at this MSDN page, specifcally this bit:
你必须迭代中继器行......
You have to iterate repeater rows....