Datasource not set when using search box

2 posts, 0 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 17 Oct 2013 Link to this post

    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

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Oct 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top