I am using HyperLink inside the repeater control for showing categories and counting data rows, i want to add css class based on data row counting from code behind.
like this:
if (dt.Rows.Count > 10)
{
//add css class to 'HyperLink9' that is being used inside the repeater control
}
asp.net code
<asp:Repeater ID="CloudTags" runat="server">
<ItemTemplate>
<asp:HyperLink ID="HyperLink9" runat="server">
<%#DataBinder.Eval(Container,"DataItem.Category")%>
(<%#DataBinder.Eval(Container,"DataItem.cnt")%>)
</asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
code behind
protected void BindRepeaterData()
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT id, category, ( SELECT COUNT(id) FROM entry_table WHERE category.id = entry_table.cat_id) as cnt FROM category", con);
DataTable dt = new DataTable();
da.Fill(dt);
CloudTags.DataSource = dt;
if (dt.Rows.Count > 10)
{
//i want to add css class here if row count is greater than 10 in 'HyperLink9'
}
CloudTags.DataBind();
con.Close();
}
on page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeaterData();
}
}
HyperLink9.CssClass = "someclass"? - Morpheus