Thanks for contacting Syncfusion support.
Query: Error thrown as “ The DatasourceID of Grid1 must be the ID of a control of type IDatasource”.
We have analyzed your query and we suspect that you bind the SqlDataSource in Grid. If we miss to add the SqlDataSource connecting string in the Grid code then the reported issue get reproduced.
Please ensure that you have add the SqlDataSource connection string to the sample and the ID given in the SqlDataSource connection string, DataSourceID value of ejGrid property both are same.
Refer the below code example.
<ej:Grid ID="Grid1" runat="server" DataSourceID="SqlData" Query ="new ej.Query().from('Orders').select(['OrderID', 'CustomerID', 'EmployeeID', 'ShipCity', 'Freight']).take(5)">
<EditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" EditMode="Dialog" />
<ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
<asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
We have prepared a sample and it can be downloadable from the below location.
If you still face the same issue then please get back to us with the following details for better assistance.
- Screen shot or video demonstration of the issue.
- Share the Grid code example.
- Essential studio version.
- Stack trace of the issue.
- If possible share the sample or reproduce the issue in the attached sample.