This is a migrated thread and some comments may be shown as answers.

Datasource not set when using search box

1 Answer 496 Views
SearchBox
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 17 Oct 2013, 09:09 PM
Hi

This is my first time at using this control, and using the most basic markup:

<telerik:RadSearchBox ID="rsbSearch" runat="server" ></telerik:RadSearchBox>

I get a 'message from webpage' error saying 'Datasource not set' for every character. When I get past this I get the search string in the .Search event.
What am I doing wrong?

Andy

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Oct 2013, 10:19 AM
Hi Andy,

By default the AutoComplete functionality of the RadSearchBox is enabled and for every character you enter, the data from the DataSource that matches with the search text will be displayed in a drop down just like how the RadAutoCompleteBox works. So if you have not set any DataSourceID and have the AutoComplete functionality enabled, the control will display a message as you described since it does not have any idea from where the matching entries should be populated in the drop down. To avoid this you can set the EnableAutoComplete property of the RadSearchBox to false when you does not have any DataSource set.

In case if you want to use the AutoComplete functionality, you can have a look at the following sample I tried which works fine.

ASPX:
<telerik:RadSearchBox ID="rsbSearch" DataSourceID="SqlDataSource1" DataTextField="ContactName"
    runat="server" OnClientSearch="OnClientSearch">
</telerik:RadSearchBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="select ContactName from [Customers]"></asp:SqlDataSource>

Hope this helps,
Shinu.
Tags
SearchBox
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or