There is a following mark-up code:
ASPX Page
<asp:Repeater ID="GeneralRepeater" runat="server"
OnItemDataBound="GeneralRepeater_OnItemDataBound">
<ItemTemplate>
<tr>
<td>
Place:
<asp:DropDownList ID="GeneralDDL" DataTextField="Text"
DataValueField="Arena" runat="server" />
</td>
<th>
<asp:Button ID="GeneralButton" runat="server"
Text="Принять запрос" onclick="GeneralButton_Click" />
</th>
</tr>
</ItemTemplate>
</asp:Repeater>
Code-behind
protected void GeneralRepeater_OnItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList myDDL = (DropDownList)e.Item.FindControl("GeneralDDL");
myDDL.DataSource = lstArenaSelect;
myDDL.DataBind();
MyObject obj= (MyObject)e.Item.DataItem;
Button GeneralButton = (Button)e.Item.FindControl("GeneralButton");
AcceptGeneralRequestButton.CommandArgument = obj.Id;
}
}
This shows the initialization of each DropDownList
with a list of objects, and each button in the row linking to the row object.
In the GeneralButton_Click
method I can get ID
of the object bound to the repeater.
Question
How do I get value from the DropDownList
that is located in the same repeater row?