I have a simple grid where I allow sorting. the datasource is filled with the needdatasource event. This funtion puts an IEnumerable<Canidate> into the datasource.
When I click the header of a column for the first time, everything works wel. When I click the header of the column next to the previous column, the column to right of the column I clicked is then sorted. also the sortmode is not changing when click multiple times on the same header. I have also tested this with auto generate columns, but this produces the same error.
Does anyone has an idea what is going on?
here is my code behind:
here is my ascx
here is my Candidate class:
When I click the header of a column for the first time, everything works wel. When I click the header of the column next to the previous column, the column to right of the column I clicked is then sorted. also the sortmode is not changing when click multiple times on the same header. I have also tested this with auto generate columns, but this produces the same error.
Does anyone has an idea what is going on?
here is my code behind:
protected void CandidateListGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
{ |
RadComboBox lastNameInput = (RadComboBox)FilterData.FindControl("LastNameInput"); |
RadComboBox firstNameInput = (RadComboBox)FilterData.FindControl("FirstNameInput"); |
RadDatePicker dateLastContractFromInput = (RadDatePicker)FilterData.FindControl("DateLastContractFromInput"); |
RadDatePicker dateLastContractUntilInput = (RadDatePicker)FilterData.FindControl("DateLastContractUntilInput"); |
RadComboBox StatusComboBox = (RadComboBox)FilterData.FindControl("StatusComboBox"); |
var statusItems = from itm in StatusComboBox.Items |
where ((CheckBox)itm.FindControl("CheckBox")).Checked |
select itm.Value; |
CandidateListGrid.DataSource = this.presenter.ListCandidates( |
((lastNameInput != null) ? lastNameInput.Text : "") |
, ((firstNameInput != null) ? firstNameInput.Text : "") |
, statusItems |
, ((dateLastContractFromInput != null) ? dateLastContractFromInput.SelectedDate : DateTime.MinValue) |
, ((dateLastContractUntilInput != null) ? dateLastContractUntilInput.SelectedDate : DateTime.MinValue) |
); |
} |
here is my ascx
<telerik:RadGrid ID="CandidateListGrid" runat="server" AllowPaging="True" AllowSorting="true" GridLines="None" |
AutoGenerateColumns="False" PageSize="10" |
AllowMultiRowSelection="True" EnableEmbeddedSkins="False" Skin="USGFOEXTelerik" |
OnNeedDataSource="CandidateListGrid_NeedDataSource" > |
<MasterTableView ClientDataKeyNames="ID"> |
<Columns> |
<telerik:GridBoundColumn DataField="LastName" HeaderText="Naam" SortExpression="LastName" |
UniqueName="LastName"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="FirstName" HeaderText="Voornaam" SortExpression="FirstName" |
UniqueName="FirstName"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ContractState" HeaderText="Status" SortExpression="ContractState" |
UniqueName="ContractState"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="LastContractDate" DataType="System.DateTime" |
HeaderText="Laatste contract" SortExpression="LastContractDate" UniqueName="LastContractDate"> |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
public class Candidate |
{ |
public int Id { get; set; } |
public string FirstName { get; set; } |
public string LastName { get; set; } |
public DateTime LastContractDate { get; set; } |
public string ContractState { get; set; } |
} |