I have not been able to figure out why I am not getting the filter results I am expecting. In fact I always get no results.
When the page first loads all the data is displayed as expected.
When I enter as search query and click the Search button the RadListView control refreshes with no results. I see the spinner so I know it posted back via AJAX.
I debug the C# code and I can confirm that the search query value is passed to the BuildExpression for the filter. No errors or exceptions are thrown.
If I submit an empty query it should just Clear the Filter and all results should show, but that does not happen.
The datasource is a List<DeviceSearchResult>.
Any ideas?
Here is my markup:
<
asp:Panel
ID
=
"pnlSearchView"
runat
=
"server"
Visible
=
"True"
>
<
h1
>Search View</
h1
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"txtDeviceSearchQuerySubmit"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"lvDeviceSearchResults"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
asp:TextBox
ID
=
"txtDeviceSearchQuery"
runat
=
"server"
></
asp:TextBox
>
<
asp:Button
ID
=
"txtDeviceSearchQuerySubmit"
runat
=
"server"
OnClick
=
"txtDeviceSearchQuerySubmit_OnClick"
Text
=
"SEARCH"
/>
<
telerik:RadListView
ID
=
"lvDeviceSearchResults"
RenderMode
=
"Lightweight"
runat
=
"server"
OnNeedDataSource
=
"lvDeviceSearchResults_NeedDataSource"
ItemPlaceholderID
=
"phDeviceSearchResult"
>
<
LayoutTemplate
>
<
asp:PlaceHolder
ID
=
"phDeviceSearchResult"
runat
=
"server"
></
asp:PlaceHolder
>
</
LayoutTemplate
>
<
ItemTemplate
>
<%# ShowGroupRow(Eval("DeviceManufacturer").ToString())=="yes"
? "<
div
class=\"manufacturer\"><
strong
>"+Eval("DeviceManufacturer")+"</
strong
></
div
>"
: "" %>
<
div
>- <%# Eval("DeviceName") %> | <%# Eval("DevicePackage") %> | <%# Eval("DevicePin") %></
div
>
<
asp:ListView
ID
=
"lvDeviceSearchResultAdapters"
runat
=
"server"
ItemPlaceholderID
=
"phDeviceSearchResultAdapters"
DataSource='<%# Eval("DeviceAdapters") %>'>
<
LayoutTemplate
>
<
ul
><
asp:PlaceHolder
ID
=
"phDeviceSearchResultAdapters"
runat
=
"server"
/></
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
><%# Container.DataItem.ToString() %></
li
>
</
ItemTemplate
>
</
asp:ListView
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
asp:Panel
>
Here is my C#:
protected
void
lvDeviceSearchResults_NeedDataSource(
object
sender, RadListViewNeedDataSourceEventArgs e)
{
lvDeviceSearchResults.DataSource = TempDeviceSearchResults.OrderBy(d => d.DeviceManufacturer).ThenBy(d =>d.DeviceName);
}
protected
void
txtDeviceSearchQuerySubmit_OnClick(
object
sender, EventArgs e)
{
lvDeviceSearchResults.FilterExpressions.Clear();
var query = txtDeviceSearchQuery.Text.Trim();
if
(!
string
.IsNullOrEmpty(query))
{
lvDeviceSearchResults.FilterExpressions.BuildExpression(ex => ex
.Contains(
"DeviceName"
, query)
);
}
lvDeviceSearchResults.Rebind();
}