RadAutoCompleteBox within InsertItemTemplate in a RadGrid with DataSourceID set

2 posts, 0 answers
  1. Harald
    Harald avatar
    3 posts
    Member since:
    Jan 2018

    Posted 08 Oct 2018 Link to this post

    I use a RadAutoCompleteBox with DataScouceID set inside an InsertItemTemplate of a RadGrid. When clicking on add-record button i got a 'DataSource not set' exception. I have to use the OnDataSourceSelect function to manually control the amount of data. It seems that the databounding has to be earlier. I tried to set the DataSource in the ItemCreate event on the RadGrid, and do not use the DataScouceID property. But in this case, I got an ReadOnlyDataSource in the OnDataSourceSelect event passed and the solution provided below does not work any more. 

    Could you please tell me what to do in order to keep the function txtSciMapUser_DataSourceSelect as it is?

    Thanks a lot.

     

    protected void txtSciMapUser_DataSourceSelect(object sender, AutoCompleteBoxDataSourceSelectEventArgs e)
    {
        SqlDataSource source = (SqlDataSource)e.DataSource;
        RadAutoCompleteBox autoCompleteBox = (RadAutoCompleteBox)sender;
     
        string filterString = e.FilterString;
        string likeCondition = string.Format("'{0}{1}%'", autoCompleteBox.Filter == RadAutoCompleteFilter.Contains ? "%" : "", filterString);
     
        source.SelectCommand = "SELECT TOP 100 * FROM sm_user WHERE [" + autoCompleteBox.DataTextField + "] LIKE " + likeCondition;
    }
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4656 posts

    Posted 09 Oct 2018 Link to this post

    Hello Harald,

    Could you try moving the declarative data source out of the grid so it is directly on the page?

    Also, if performance is an issue, I'd suggest you consider fetching the data from a web service (or, of course, a WCF web service). This will reduce the number of requests made for the current page and thus reduce the load on the server and is likely to work faster for the end user as well.


    Regards,
    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top