Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Look at the below picture I want to count value of last column (cnt) I am using repeater control.

https://lh5.googleusercontent.com/-M7W6AuZ1VG8/U_rQhXAxUOI/AAAAAAAABGg/wwt1Lv1TpfA/w426-h451/Untitled-1.jpg[^]

what i want?
C#
if (last column (cnt) is greater than 5> )
{
    response.write ("6");
}


sql query

SELECT id, category, ( SELECT COUNT(id) FROM entry_table WHERE category.id = entry_table.Cat_id) as cnt FROM category


Repeater code
C#
<asp:Repeater ID="CloudTags" runat="server"  OnItemDataBound="CloudTags_ItemDataBound">
    <ItemTemplate>
        <asp:HyperLink ID="HyperLink9" runat="server">
             <%#DataBinder.Eval(Container,"DataItem.Category")%>
            (<%#DataBinder.Eval(Container,"DataItem.cnt")%>)
        </asp:HyperLink>
    </ItemTemplate>
</asp:Repeater>


Code behind:
C#
protected void CloudTags_ItemDataBound(object sender, RepeaterItemEventArgs e)
{

}
Posted

1 solution

You can check the item type in ItemDataBound Event. Then try this:
C#
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem){
    MyCount += Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "column_name"));
//MyCount is variable which is declared globaly
}


--Amy
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900