Hi @jewel,
I have test your code and will share with you. But I still can't point the error directly, you can follow my steps to fix it by yourself.
1.Import jquery datatable js file.
<!-- #region datatables files -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" />
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" asp-append-version="true"></script>
- Open the F12 Browser Developer Tools, and set breakpoint here to check if the data is returned or not.
3.Set breakponit in your backend api, make sure we have queried the data from database. And please notice, we should use Json(data)
here.
4.If there no data returned in the controller, we need to double check the database connectionstring, make sure we have connected to correct database. And we also could copy the sql query sentence and query it in tools(like SSMS), make sure the sql query sentence is correct.
5.Test Result
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Jason