Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to coloring my repeater row when there is such a below condition

i a having a column named FamilyID, when family id is same for Below Row then i need to change the color, else change the other color.
for eg
familyid

1 This is Same ID so Any Color

1 This is Same ID so previous Color

1 This is Same ID so previous Color

2 Not Same ID in compare to above ---Any Next Color but not its previous

2 This is Same ID so previous Color

3 Not Same ID in compare to above ---Any Next Color but not its previous

4 -Not Same ID in compare to above ---Any Next Color but not its previous

What I have tried:

Don't know how to achieve or where to start.
Posted
Updated 17-Oct-19 2:37am
v2

1 solution

You need to look at the various Repeater Events. One that might work is the ItemCreated event, Repeater.ItemCreated Event (System.Web.UI.WebControls) | Microsoft Docs[^] or possibly the ItemDataBound event, Repeater.ItemDataBound Event (System.Web.UI.WebControls) | Microsoft Docs[^]

However, if you're trying to compare with the one below it then the one below won't exist when these events fire so you may have to loop through all of the items during one of the page events, possibly LoadComplete or PreRender, Understanding the order of ASP.NET Page events[^]

Another option is to compare in SQL and return a flag that can be used in the ItemDataBound event.
 
Share this answer
 
v2
Comments
Anuragintit 18-Oct-19 3:07am    
Thanks, but i solved it with loop taking first as 0 and compre to first row then assign value string then second compare return the true of false.... and so on..

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