问题是我无法将数据从模型传递到PartialView。我是这样做的。
我的PartialsController.cs
public PartialViewResult _GridView()
{
var currentUser = UserManager.FindById(User.Identity.GetUserId());
var ranks = ApplicationDbContext.Ranks.ToList();
foreach (var item in ranks)
{
if (currentUser.ReputationPoints > item.ReputationPoints && currentUser.ReputationPoints < item.PointsToAdvance)
{
currentUser.UserRankId = item.Id;
ApplicationDbContext.Entry(currentUser).State = EntityState.Modified;
ApplicationDbContext.SaveChanges();
}
}
var Rank = ApplicationDbContext.Ranks.SingleOrDefault(c => c.Id == currentUser.UserRankId);
return PartialView(currentUser);
}
我的部分视图称为_GridView.cshtml
@model Destiny.Models.ApplicationUser
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Zalogowano jako " + Model.CurrentUser.Gamertag, "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Wyloguj</a></li>
</ul>
}
}
else
{
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Zarejestruj", "Register", "Account",routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Zaloguj", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
</ul>
}
partialView需要另一个ViewModel(顺便说一句,它用于我的主页/索引),事实是我100%确定我在传递数据方面做错了,但我不是&# 39;不知道它是什么。这是我第一次搞乱部分观点。
答案 0 :(得分:2)
使用
void
test_ver()
{
uint8_t reg=1;
// Get the MFRC522 firmware version
uint8_t v = 0;
while(reg!=0xa){
v = read_register_rfid(0x37);
//printf("%x\n", v);
// Lookup which version
switch(v) {
case 0x88: printf(" = (clone)"); break;
case 0x90: printf(" = v0.0"); break;
case 0x91: printf(" = v1.0"); break;
case 0x92: printf(" = v2.0\n"); break;
// default: printf(" = (unknown)\n");
}
reg++;
//When 0x00 or 0xFF is returned, communication probably failed
}
if ((v == 0x00) || (v == 0xFF))
printf("WARNING: Communication failure?\n");
}
而不是
@Html.RenderAction
这种方式
@Html.Partial( in the layout –