I thought this would be a simple issue, but I've been struggling. I created an image button in my header template. When clicked, it calls the Sorting method. When I change the image url in code behind, it does not render. By setting a break point, I can see the property being updated, but I assume it is getting overridden by the default I set in the HTML page.
Code:<HeaderTemplate> <span>Claim Id</span> <asp:ImageButton ID="btnClaimIdSort" runat="server" ImageUrl="~/Styles/UpArrow.ico" OnClick="Sorting" ToolTip="ClaimId" /> </HeaderTemplate>Code:protected void Sorting(object sender, EventArgs e) { var sortButton = (ImageButton)sender; // parse new sort var newField = sortButton.ToolTip; // parse existing sort var existingSortArgs = this.ClaimSort.Split(' '); var existingField = existingSortArgs[0]; var existingDirection = existingSortArgs[1]; if (string.Compare(newField, existingField,true) == 0) { // swap direction var newDirection = (existingDirection == "Asc" ? "Desc" : "Asc"); sortButton.ImageUrl = (newDirection == "Asc" ? "~/Styles/DownArrow.ico" : "~/Styles/UpArrow.ico"); this.ClaimSort = string.Format("{0} {1}", existingField, newDirection); } else { sortButton.ImageUrl = "~/Styles/UpArrow.ico"; this.ClaimSort = string.Format("{0} Asc", newField); } // rebind data this.BindResultsGrid(); }




Reply With Quote