I have a grid with 7 columns of which 3 are checkboxes. I have applied sorting in the grid as shown below :-
When I click on any of the column headers the grid is sorted correctly for the first 4 columns. However the 3 checkbox columns are not re-ordered according to the newly sorted grid. I am attaching screenshots for "Grid before sorting" and "Grid After Sorting" to get a better idea. The 3 chkbox columns are manipulated in the itemdatabound event of the rad grid. The code of item databound event is as follows :-
Let me know how can I solve this issue and get the sorting right.
<telerik:RadGrid ID="grdSearchResults" runat="server" AllowSorting="true" GridLines="None" Skin="Windows7" AutoGenerateColumns="False" PageSize="5" onitemdatabound="grdSearchResults_ItemDataBound" onneeddatasource="grdSearchResults_NeedDataSource" > <ClientSettings EnablePostBackOnRowClick="true" EnableRowHoverStyle="true"> </ClientSettings> <MasterTableView Width="100%" TableLayout="Auto" CommandItemDisplay="Top" AllowPaging="true" AllowSorting="true" PageSize="10" > protected void grdSearchResults_ItemDataBound(object sender, GridItemEventArgs e) { try { if (e.Item is GridDataItem) { DataTable dt = (DataTable)ViewState["StatementList"]; if (dt != null) { string credit = dt.Rows[e.Item.ItemIndex]["CreditImage"].ToString(); string BackImages = dt.Rows[e.Item.ItemIndex]["BackImage"].ToString(); string AddImages = dt.Rows[e.Item.ItemIndex]["Image"].ToString(); CheckBox chkCredits = (CheckBox)e.Item.FindControl("chkCredits"); CheckBox chkBackImages = (CheckBox)e.Item.FindControl("chkBackImages"); CheckBox chkAddImages = (CheckBox)e.Item.FindControl("chkAddImages"); if (credit == "True") chkCredits.Checked = true; else chkCredits.Checked = false; if (BackImages == "True") chkBackImages.Checked = true; else chkBackImages.Checked = false; if (AddImages == "True") chkAddImages.Checked = true; else chkAddImages.Checked = false; } } } catch (Exception ex) { Log.WriteLine(LogParams.USERCONTROLS, "StatementGrid : grdSearchResults_ItemDataBound : " + ex.Message, LogLevel.Error, LogParams.ERRORMSG); LoadDummyData(); } }