我正在尝试在视图内的标签中显示数据,数据来自另一个视图,为此我已经这样做了
这是我的模型
namespace MvcSampleApplication.Models
{
public class products
{
[Required]
[Display(Name = "Textbox1")]
public string EnteredValue { get; set; }
}
public class category
{
[Display(Name = "Label1")]
public string lablvalue { get; set; }
}
}
这是我的控制器
namespace MvcSampleApplication.Controllers
{
public class EnterValueController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Valuesadd(MvcSampleApplication.Models.products model)
{
return View(model);
}
[HttpPost]
public ActionResult SubmitValue(MvcSampleApplication.Models.products model)
{
ViewData["logindata"] = model.EnteredValue;
return View("submittedvalues");
}
public ActionResult submittedvalues()
{
var model = new MvcSampleApplication.Models.category();
string data = ViewData["logindata"] != null ? ViewData["logindata"].ToString() : "";
model.lablvalue = data;
return View(model);
}
}
}
这是我的观点
@model MvcSampleApplication.Models.category
@{
ViewBag.Title = "submittedvalues";
}
<h2>submittedvalues</h2>
@using (Html.BeginForm())
{
<div>
<fieldset>
<legend>
Lable value
</legend>
@Html.DisplayFor(s=>s.lablvalue)
</fieldset>
</div>
}
当我按下提交按钮时,它将查看(submittedvalues.cshtml)但不显示结果非常感谢....