Hi
Message = "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource."
SAPbobsCOM.SBObob obj = _oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
SAPbobsCOM.Recordset rs = _oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
rs = obj.GetBPList(SAPbobsCOM.BoCardTypes.cCustomer);
int count = rs.RecordCount;
rs.DoQuery("SELECT CardCode,CardName FROM OCRD");
grdBP.DataSource = rs;
grdBP.DataBind();
Thanks
Ramco RamcoPosted Dec 30, 2023, 3:55 AM
Hi Jignesh
I am not getting tolist option
Thanks
Jignesh KumarPosted Dec 29, 2023, 11:36 AM
Hello Ramco,
Have you check what it return type of this ?
You need to change here, just convert above one into list.
Prasad RaveendranPosted Dec 29, 2023, 4:29 AM
Here's an example of how you might resolve this issue by converting the
Recordsetto a compatible data source before binding it togrdBP. You can use aDataTableas an intermediary data structure:This code creates a
DataTable, fills it with the data from theRecordset, and then sets theDataTableas the data source forgrdBP.Remember to replace
DataGridViewwith the appropriate UI control that you're using in your application (e.g., GridView, DataGrid, etc.).This approach ensures that the data source (
DataTable) being assigned to the grid control is compatible with the data binding requirements.Asma KhalidPosted Dec 28, 2023, 6:25 PM
The main issue you are facing is that your data source is basically a table and you are assigning a table to a set of rows. YOu need to initiate dataable variable to mapp the table as data source.
Thanks & Regards,
Jayraj ChhayaPosted Dec 28, 2023, 9:09 AM
The error message "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource" suggests that the
CauseDataSourceproperty of thegrdBPcontrol is expecting a specific type, but the providedrsobject does not match that type.The cause of the issue is that the
SolutionDataSourceproperty of thegrdBPcontrol expects a data source that implements either theIListSource,IEnumerable, orIDataSourceinterface. However, thersobject in the code is of typeSAPbobsCOM.Recordset, which does not implement any of these interfaces.To resolve the issue, we need to convert the
Recordsetobject to a compatible data source type before assigning it to theDataSourceproperty of thegrdBPcontrol. One way to achieve this is by converting theRecordsetto aDataTableobject, which implements theIListSourceinterface.Here's an updated version of the code that includes the necessary conversion:
In the updated code, we create a new
DataTableobject and load the data from theRecordsetusing theLoadmethod. This converts theRecordsetinto aDataTablethat can be assigned to theDataSourceproperty of thegrdBPcontrol.Satyaprakash SamantarayPosted Dec 28, 2023, 8:09 AM
Make sure you should use the item it fills and for this u can load the data into a
DataTableand then set theDataTableas the data source for your gridview control.Refer below link,
https://www.experts-exchange.com/questions/23196023/Error-Data-source-is-an-invalid-type-It-must-be-either-an-IListSource-IEnumerable-or-IDataSource.html
Vijay Pratap SinghPosted Dec 28, 2023, 7:00 AM
To resolve this issue, you need to convert the data from the
Recordsetto a suitable data structure that implements one of the required interfaces. One common approach is to load the data into aDataTableand then set theDataTableas the data source for your grid.Hope this will help