Click here to Skip to main content
15,943,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have implemented a repeater control which has some columns and data. For each column header, in the header template, I have defined a label for the header text and an <asp:Image/> tag for showing the direction of sorting (asc or desc). Sample code below:
<th align="left" class="HeaderCell">
 <div class="HeaderCellPadding"> 
    <asp:LinkButton ID="business_name" runat="server" CommandName="business_name"/>
    <asp:Image ID="img_business_name" runat="server" /> 
..... and so on similarly for other header columns

Initially, these images are not shown (I'm setting their Visible property to false in ItemDataBound). But when any of the column headers are clicked, this image should show the corresponding direction of sort.

Just like any other sort direction display....

Initially, in my code, I wrote the visibility toggling of these images in the ItemCommand event handler based on the command name sent. But no matter how hard I tried, these images were not showing up on the click of those headers.

However, after I put this toggling logic in the ItemDataBound event handler, the images started showing up as expected.

Can someone please explain how this makes any difference?


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