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

RadAutoCompleteBox within InsertItemTemplate in a RadGrid with DataSourceID set

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harald
Top achievements
Rank 1
Harald asked on 08 Oct 2018, 08:55 AM

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;
}

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Oct 2018, 07:13 PM
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.
Tags
Grid
Asked by
Harald
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or