Amogh Natu

Amogh Natu

  • NA
  • 700
  • 313.7k

Repeater control's sort direction image not displaying

Mar 6 2014 8:33 AM
Hi,
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 class="HeaderCell">
<div class="HeaderCellPadding">
<asp:LinkButton ID="business_name" runat="server" CommandName="business_name"/>
<asp:Image ID="img_business_name" runat="server" />
</div>
</th>
..... and so on similarly for other header columnsInitially, 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?
Thanks.