SearchBox Error

4 posts, 0 answers
  1. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 23 May 2014 Link to this post

    I'm programmatically binding data to a RadSearchBox [I get my data list back from a Service Reference] and I set the DataTextField and DataValueField, then I set the DataSource - all without errors.  However, when I start typing in the search box, I receive a popup on the page: DataSource not set

    What am I missing?
    <telerik:RadSearchBox runat="server" ID="radTest" OnSearch="radTest_OnSearch"></telerik:RadSearchBox>

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        UserServiceClient client = new UserServiceClient();
        var users = client.GetSecurityUsers().ToList();
        radTest.DataTextField = "full_name";
        radTest.DataValueField = "user_id";
        radTest.DataSource = users;
      }
    }
    protected void radTest_OnSearch(object sender, SearchBoxEventArgs e)
    {
      UserServiceClient client = new UserServiceClient();
      var users = client.GetSecurityUsers().ToList();
      if (!string.IsNullOrEmpty(e.Text))
      {
        users = users.Where(i => i.full_name.Contains(e.Text)).ToList();
      }
      radTest.DataTextField = "full_name";
      radTest.DataValueField = "user_id";
      radTest.DataSource = users;
    }



  2. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 27 May 2014 Link to this post

    Hello Mike,

    Please try to bind the data source on Page_Load:

    protected void Page_Load(object sender, EventArgs e)
    {
        BindToList(RadSearchBox1);
    }
     
    private void BindToList(RadSearchBox searchBox)
    {
        UserServiceClient client = new UserServiceClient();
        var users = client.GetSecurityUsers().ToList();
        searchBox.DataTextField = "full_name";
        searchBox.DataValueField = "user_id";
        searchBox.DataSource = users;
    }

    If this doesn't help, please provide me with a very simplified runnable project, which I can inspect locally and advise you further.

    You can also check the following article on how to bind to array or array list:
    http://www.telerik.bg/help/aspnet-ajax/searchbox-databinding-array.html

    Regards,
    Aneliya Petkova
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 28 May 2014 in reply to Aneliya Petkova Link to this post

    I've got a test app (zipped) that has the error in it, where can I send the zip file to?
  5. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 29 May 2014 Link to this post

    Hello Mike,

    File attachments are not supported in the Telerik Forum.
    If you want to send us your project, you should start a new support ticket. Please include there the url of this forum thread. That will help us to track the problem easier.

    Regards,
    Aneliya Petkova
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top