I have a stored procedure GetAllUsers which returns all the columns from a the table Users.
Here is a sample of a the DataTable I want to achieve:
I'm using Entity Framework (database-first approach).
Stored procedure:
ALTER PROCEDURE [dbo].[GetAllUsers]
AS
BEGIN
SELECT *
FROM Users
END
Controller:
public ActionResult Index()
{
// Create ViewModel/ResourcViewModel instance
var vm = new ResourceViewModel();
// Code to fetch data from stored procedure and display to DataTable
}
View model:
public class ResourceViewModel
{
public int UserID { set; get; }
public string FirstName { set; get; }
public string LastName { set; get; }
}
View:
<table class="table" id="dataTable">
<thead>
<tr>
<th class="text-center">First Name</th>
<th class="text-center">Last Name</th>
<th class="text-center">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Wick</td>
<td><button class="btn btn-xs btn-primary" data-toggle="modal" data-target="#exampleModal">iew Details</button>
</td>
</tr>
<tr>
<td>Black</td>
<td>Panther</td>
<td><button class="btn btn-xs btn-primary" data-toggle="modal" data-target="#exampleModal">View Details</button>
</td>
</tr>
</tbody>
</table>
Once I have displayed the list of users into the DataTable. I also want to know how to bind the UserID to my View Details button.

select * from usersdoesn't need a stored procedure don't you think ?UserID.select * from Users where id=myvariable?!!