我有一个带有文字、下拉列表和按钮的转发器。
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="rep_ItemDataBound" onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<div class="buypanel">
<ul>
<li>Choose finish <asp:DropDownList ID="ddlFinish" runat="server"></asp:DropDownList></li>
<li>Qty <asp:Literal ID="ltQty" runat="server"></asp:Literal></li>
<li><asp:Button ID="butBuy" runat="server" Text="Button" /></li>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
我正在绑定代码中的所有信息,例如
protected void rep_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Products product = (Products) e.Item.DataItem;
//Dropdownlist to be bound.
//Set Buy Button
var butBuy = (Button) e.Item.FindControl("butBuy");
butBuy.CommandName = "Buy";
butBuy.CommandArgument = product.Id.ToString();
}
}
我让我的 itemcommand 拿起按钮点击
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if(e.CommandName == "Buy")
{
}
}
我不确定如何通过给定的按钮单击从文本框和旁边的下拉列表中获取正确的信息?