<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr>
<td><%#subtypes.FindByPk(Convert.ToInt32(Eval("SubitemID"))).title%></td>
<td><%#Eval("quantity")%></td>
<td><%#ThanaRecord.FindByPk(Convert.ToInt32(Eval("Thanaid"))).title%></td>
<td><%#Eval("created_at")%></td>
<td> <% if (Employee.GetCurrentEmployee().role == "Admin") { %>
<a href="AddDemand.aspx?type=update&id=<%#Eval("id")%>">EDIT</a>
<a href="AddDemand.aspx?type=delete&id=<%#Eval("id")%>">DELETE</a>
<% } %>
<%if (Employee.GetCurrentEmployee().role == "SuperVisor")
{ %>
<asp:DropDownList ID="DropDownList1" runat="server" Width="120px" CssClass="form-control">
<asp:ListItem>Accept</asp:ListItem>
<asp:ListItem>Reject</asp:ListItem>
</asp:DropDownList>
<%--<asp:textbox runat="server" id="textTest"></asp:textbox>--%>
</td>
<%} %>
</tr>
</ItemTemplate>
</asp:Repeater>
Where do you want to access it? However, in general you have to use RepeaterItem.FindControl("DropDownID")
to get the reference.
For example in ItemDataBound
:
protected void Repeater1_ItemDataBound(Object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList ddldrop = (DropDownList) e.Item.FindControl("DropDownList1");
// here you are
}
}
If you want to access it from a button-click handler where the button is outside of the repeater you can loop all the items via repeater.Items
. You don't need to check the ListItemType
as in the code above if you loop the repeater-items since repater.Items
only returns items with type Item
and AlternatingItem
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.