A Textbox (RadTextBox) is supposed to filter a ListView (RadListView) through the use of an ObjectDataSource's FilterExpression. The underlying datasource of the ObjectDataSource is a WCF Service.
It is not working. In all of my trial and error, all I can get was the entire dataset to bind to the ListView or no records at all. I was not able to get a select few records by filtering it from input in the Textbox.
Here is a helper video (a bit desperate at this point...)
Thanks in advance!
RadListView:
<telerik:RadListView ID="RadListView1" runat="server"
DataSourceID="ObjectDataSource1" AllowPaging="True"
ItemPlaceholderID="ListingsContainer" Width="940px" SkinID="Bootstrap">
ObjectDataSource:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnablePaging="true" TypeName="manageListingsController" SelectMethod="GetProducts" StartRowIndexParameterName="startRowIndex"
SelectCountMethod="GetProductsCount" FilterExpression="ItemID = '{0}%'" InsertMethod="InsertProduct" DeleteMethod="DeleteProduct" UpdateMethod="UpdateProduct" OldValuesParameterFormatString="Original_{0}" SortParameterName="sortExpression">
<FilterParameters>
<asp:ControlParameter Name="@ItemID" ControlID="txtItemID" ConvertEmptyStringToNull="false" Type="String" />
</FilterParameters>
<InsertParameters>
<asp:Parameter Name="ItemID" Type="String" />
<asp:Parameter Name="SiteID" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="ProductID" Type="String" />
<asp:Parameter Name="Condition" Type="String" />
<asp:Parameter Name="ToAP" Type="Boolean" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ItemID" Type="String" />
<asp:Parameter Name="SiteID" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="ProductID" Type="String" />
<asp:Parameter Name="Condition" Type="String" />
<asp:Parameter Name="ToAP" Type="Boolean" />
<asp:Parameter Name="Original_ID" Type="Int32"></asp:Parameter>
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="ItemID" Type="String" />
<asp:Parameter Name="SiteID" Type="Int32" />
<asp:Parameter Name="Original_ID" Type="Int32"></asp:Parameter>
</DeleteParameters>
</asp:ObjectDataSource>
GetProducts Method:
public DataTable GetProducts(int startRowIndex,
int maximumRows,
string sortExpression)
{
ProductsAPI.ProductsClient pCl = new ProductsAPI.ProductsClient();
DataTable n = new DataTable();
try
{
rowCount = temp.Count;
try
{
n = Help.ToDataTable(temp.ProductData.ToList());
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(null, ex);
}
return n;
}
WCF GetProducts OperationContract:
[OperationContract]
public ResultData GetProducts(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
DAL.Products.Products p = DAL.Products.Products.Instance();
return p.GetDataAndCount(startRowIndex, maximumRows, sortExpression, filterExpression);
}
WCF GetDataAndCount Method:
public ResultData GetDataAndCount(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
//http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/declarative/defaultcs.aspx
//http://demos.telerik.com/aspnet-ajax/listview/examples/client/webservicedatabinding/defaultcs.aspx
GridLinqBindingData<v_mp_GenListings_Data> data = RadGrid.GetBindingData(
(new Entities()).v_mp_GenListings_Data.OrderByDescending(p => p.ProductID),
startRowIndex, maximumRows, sortExpression, filterExpression);
ResultData result = new ResultData();
result.ProductData = data.Data.OfType<v_mp_GenListings_Data>().Select(p => new Product()
{
ItemID = p.ItemID,
SKU = p.SKU,
ID = p.ID,
SiteID = p.SiteID,
MarketPlaceType = p.MarketplaceType,
SiteName = p.SiteName,
//AccOverride = p.AccOverride,
//ToAP = p.ToAP,
//CeilingPriceFixed = p.CeilingPriceFixed,
//Min = p.Min,
NightModeID = p.NightModeID,
NightModeCode = p.NightModeCode,
ToMAP = p.ToMAP,
ConditionID = p.ConditionID,
MerchantID = p.MerchantID,
ProductID = p.ProductID,
Quantity = p.Quantity,
Price = p.Price,
URL = p.URL
}).ToList();
result.Count = data.Count;
return result;
}