I'm working on a search box that filters the information from an EntityDataSource.
I am looking for a solution that gets you the "final" DataSource, I mean the data collection that you can read after putting some letters in the search box.
Is there any way to get it?
Thank you for your attention
8 Answers, 1 is accepted
You can use the OnSearch server side event which is raised when the search button is clicked, Enter is pressed or an item from the searchbox dropdown is clicked. The event handler receives two parameters:
- The instance of the SearchBox firing the event
- An event arguments parameter that contains the following properties:
- Text - returns the text that is typed in the searchBox, or the text of the selected result item.
- Value - returns the value of the selected result item.
- DataItem - returns the dataItem that is associated with the selected result item.
Please check the following online example demonstrating similar scenario (you can do this also using EntityDataSource):
http://demos.telerik.com/aspnet-ajax/searchbox/examples/applicationscenarios/gridfilteredbysearchbox/defaultcs.aspx
Regards,
Aneliya Petkova
Telerik
See What's Next in App Development. Register for TelerikNEXT.
thank you for your answer.
I tried to follow your example using the EntityDataSource but the DataItem is always null, so I can't have any information about my searching results.
Do you have any clue or other things I should add in order to retrieve the requested DataItem?
Thank you
ID="RadSearchBox1"
EmptyMessage="Cerca..."
DataSourceID="EntityDataSource1"
DataValueField="IdHelp"
DataTextField="DatiHelp"
DataKeyNames="DatiHelp, IdHelp"
Width="300"
EnableAutoComplete="true"
OnClientSearch="lookForResults"
OnSearch="DisplayResults" >
<DropDownSettings Height="400" Width="300" />
</telerik:RadSearchBox>
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=DMWEntities"
DefaultContainerName="DMWEntities" EntitySetName="Manuale_Machina" Select="it.[IdHelp], it.[DatiHelp], it.[Titolo]"
AutoPage="true ">
</asp:EntityDataSource>
I used this code in order to use RadSearchBox, if this can help. (I also tried the SQLDataSource, but it returns the same error)
I can't see anything wrong with the code snippet you sent.
I made you a sample using EntityDataSource. Please try it and let me know if everything works ok at your side.
Regards,
Aneliya Petkova
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hello,
I tried your example and I have the same settings, for the EntityDataSource and for the object SearchBox, but I didn't get what I wanted.
Is there any possibility of retrieving the entire collection of DataItems that are showing while writing on the searchbox?
The scenario could be simulated in this way: I click on a single result and I get a DataItem, so I should click on all results to get the collection that I am looking for.
Thank you
I am not sure I understand what exactly you need to achieve and why you want to get all the filtered data. But this it is not possible using RadSearchBox control. You can try some other controls - for example RadComboBox and see if it will be suitable for your scenario.
Regards,
Aneliya Petkova
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hi Henry,
A sample on how to bind RadSearchBox with EntityDataSource is available in our documentation here:
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=NorthwindEntities35"
DefaultContainerName="NorthwindEntities35" EntitySetName="Customers" Select="it.[ContactName], it.[City], it.[ContactTitle]"
AutoPage="true" OrderBy="it.[ContactName]">
</asp:EntityDataSource>
<telerik:RadSearchBox RenderMode="Lightweight" runat="server" ID="RadSearchBox3" EmptyMessage="Entity"
DataSourceID="EntityDataSource1" DataValueField="ContactName"
DataTextField="City">
<DropDownSettings Height="400" Width="300" />
</telerik:RadSearchBox>
Regards,
Vessy
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.