Member 11882351
Член Списка, Использующий Ajax
<script src="~/Scripts/Old/jquery1.8.3.min.js"></script>
<script src="~/Scripts/Old/jquery-1.js"></script>
<script>
$(document).ready(function () {
bindMemberList();
});
function bindMemberList() {
$.ajax({
type: "Get",
cache: false,
url: "/MemberMasters/GetMemberData",
data: { 'tableName': "MemberMasters" },
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (response) {
$("#RawDatas table tbody tr:not(:first)").remove();
$("#RawDatas table tbody tr:eq(0)").show();
for (var i = 0; i < response.length; i++) {
var table = $("#RawDatas table tbody tr:eq(0)").clone(true);
$(".memberId", table).html(response[i].MemberId);
$(".fullname", table).html(response[i].FristName + ' ' + response[i].MiddelName + ' ' + response[i].Surname);
$(".address", table).html(response[i].Address);
$(".userName", table).html(response[i].UserName);
$(".emailId", table).html(response[i].EmailId);
$("#editdata", table).attr('href', '/MemberMasters/Edit?id=' + response[i].MemberId);
$('#Deletedata', table).attr('href', '/MemberMasters/DeleteSadmin?id=' + response[i].MemberId);
$("#RawDatas table").append(table);
}
$("#RawDatas table tbody tr:eq(0)").hide();
},
failure: function (response) {
},
error: function (response) {
}
});
}
</script>
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div id="RawDatas">
<table class="table table-striped table-bordered bootstrap-datatable">
<thead>
<tr>
<th style="cursor: pointer;">
Id
</th>
<th style="cursor: pointer;">
Full Name
</th>
<th style="cursor: pointer;">
Address
</th>
<th style="cursor: pointer;">
UserName
</th>
<th style="cursor: pointer;">
Email Id
</th>
<th style="cursor: pointer;">
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="memberId"></span>
</td>
<td>
<span class="fullname"></span>
</td>
<td>
<span class="address"></span>
</td>
<td>
<span class="userName"></span>
</td>
<td>
<span class="emailId"></span>
</td>
<td>
<a class="btn btn-info" id="editdata" style="padding: 1px 7px; margin: 1px;">
Edit
</a>
<a class="btn btn-danger" id="Deletedata" style="padding: 1px 7px; margin: 1px;">
Delete
</a>
</td>
</tr>
</tbody>
</table>
</div>
Код контроллера показать данныеpublic ActionResult Index(string BackFor = "")
{
TempData["BackFor"] = BackFor;
return View();
}
public JsonResult GetMemberData(string tableName)
{
List<MemberMaster> Memberlist = new List<MemberMaster>();
Memberlist = db.MemberMasters.ToList();
return Json(Memberlist, JsonRequestBehavior.AllowGet);
}