Reputation: 7840
Items:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Repeater control I want to place class on highlighted item number.
so ... I have done following code.
if ((DL_NewProducts.Items.Count) % 3 == 0)
{
var libox = e.Item.FindControl("libox") as HtmlGenericControl;
if (libox != null)
libox.Attributes["class"] = "last";
}
Here is problem that in first iteration it find three items, mod work fine and it place class on 4th item but in second iteration it come again on 6th item and place class on 7th item while I want it to place it on 8th what will be correct logic for it..
Upvotes: 2
Views: 15913
Reputation: 113462
The question isn't completely clear - you have marked the sequence 4, 8, 12, ... in bold but appear to actually want the numbers in the sequence 3, 7, 11... to pass the test.
So I think you're looking for the expression:
DL_NewProducts.Items.Count % 4 == 3
But it's hard to tell since it isn't clear if those numbers at the top represent counts, zero-based indices or one-based indices. If you can clarify exactly what they represent and how they relate to the collection's count, we might be able to provide more appropriate answers.
Upvotes: 5