У меня есть хранимая процедура GetAllUsers
, которая возвращает все столбцы из таблицы Users
.
Вот пример таблицы данных, которую я хочу получить.

Я использую Entity Framework (База данных сначала).
Хранимая процедура
ALTER PROCEDURE [dbo].[GetAllUsers]
AS
BEGIN
SELECT * FROM Users
END
Контроллер
public ActionResult Index()
{
// Create ViewModel/ResourcViewModel instance
var vm = new ResourceViewModel();
// Code to fetch data from Stored Procedure and display to DataTable
}
Просмотр модели
public class ResourceViewModel
{
// Dropdown Properties
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>
Как только я отобразил список пользователей в DataTable. Я хочу связать UserID
с моей View Details
кнопкой.