Thanks
<
FilterTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"FilterCombo"
DataSourceID
=
"StatusList"
UniqueName
=
"StatusFilterCombo"
DataValueField
=
"StatusID"
DataTextField
=
"Status"
AutoPostBack
=
"True"
OnSelectedIndexChanged
=
"FilterCombo_SelectedIndexChanged"
>
</
telerik:RadComboBox
>
</
FilterTemplate
>
6 Answers, 1 is accepted
You can use the approach utilized for the first grid on this demo (specifying SelectedValue for the combobox filters with binding expression) to retain the selection in the comboboxes.
Best regards,
Sebastian
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks
<
telerik:GridTemplateColumn
DataField
=
"StatusID"
FilterControlAltText
=
"Filter TemplateColumn column"
HeaderText
=
"Status"
UniqueName
=
"Status"
>
<
FilterTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"FilterComboStatus"
DataSourceID
=
"StatusList"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'
DataValueField="StatusID" DataTextField="Status" AutoPostBack="True"
OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged">
</
telerik:RadComboBox
>
</
FilterTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox_StatusList"
runat
=
"server"
AutoPostBack
=
"true"
DataSourceID
=
"StatusList"
DataTextField
=
"Status"
DataValueField
=
"StatusID"
OnSelectedIndexChanged
=
"FilterCombo_SelectedIndexChanged"
SelectedValue='<%#Bind("StatusID") %>'>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "Status")%>
</
ItemTemplate
>
<
ItemStyle
Width
=
"240px"
/>
</
telerik:GridTemplateColumn
>
Does changing the DataValueField property of the combobox filter to Status (instead of StatusID) as well as the DataField property of the template column to Status makes a difference?
Note that you may also consider an alternative solution using your own column which derives from a GridTemplateColumn as demonstrated here (see the definition for the last column in the grid).
Best regards,
Sebastian
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
After I reviewed once again your code, I noticed that you perform postback when an item in the combobox filter is selected (set AutoPostBack = true for the dropdown). Can this be the reason why the combobox selection is reset, as the grid is rebound when filtering operation is triggered?
You can try the approach with client call to the filter method of the grid API as presented in the first live example I linked to compare the results. Also you can debug the value of the CurrentFilterValue property of the Status column to see whether it is set as expected (intercepting the ItemCommand event when e.CommandName is RadGrid.FilterCommandName).
Regards,
Sebastian
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
I changed my code for ClientSide events like the example you linked to and it now works. I don't know why the Sever side stuff does not work though. Oh well I'll just go with it as it is now, hell at least its working :)
Thanks for the help.