C # This row already belongs to another table
When creating a project, you need to upload the background data to the foreground and display it in the datagrid. Because multiple tables are used for joint query, therefore, the data to be displayed is stored in the DataTable in the background, and then cyclically. Each time a piece of data is found, a piece of data is passed into the DataTable. The logic of the result is adjusted and the code is written, this error is reported:
After some failed attempts, Baidu was decisive and found the solution. Because it found not only the required data, but also other things, the code should be:
Table. Rows. Add (row );
Changed:
Table. Rows. Add (row. ItemArray );
After checking, we found that ItemArray represents the data array in this row, and what we need is this, so we only need to get the data we need, however, some people say this is not easy to maintain, and I have not understood it too well. If anyone understands this, please leave a message to me.