I have one Repeater
<asp:Repeater runat="server" ID="rptID" OnItemDataBound="repID_ItemDataBound">
<ItemTemplate>
<a href='example.com/somepage.aspx' id="myLink">
<%# Eval("MyVal")%>
</a>
</ItemTemplate>
</asp:Repeater>
In Code Behind I need to add one css class for this <a>
tag when in repeater is one
Item
protected void repID_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
//how to set this class only then count of items is equal with 1
((HtmlGenericControl)e.Item.FindControl("myLink")).Attributes
.Add("class", "Count1");
}
}