看看我在做什么,用你的相关字段制作一个自定义模型,然后在 中为它们分配值controller
,并将这个值传递给View
,就是这样。:)
定制模型
public partial class QuoteParameter
{
public Nullable<System.DateTime> TripStartDateLimit { get; set; }
public Nullable<System.DateTime> TripEndDateLimit { get; set; }
public int PolicyId { get; set; }
}
控制器
public ActionResult Index()
{
QuoteParameter quote = new QuoteParameter();
quote.TripEndDateLimit = DateTime.Now;
quote.TripEndDateLimit = DateTime.Now;
quote.PolicyId = 5;
return View(quote);
}
看法
@model EHIC.Models.Models.QuoteParameter
按 Razor 语法
<div class="row-fluid span12">
<div class="span4">
<p><strong>Trip Start Date Limit :</strong></p>
</div>
<div class="span5">
@Html.TextBoxFor(model => model.TripStartDateLimit, "{0:dd/MM/yyyy}", new { @class = "form-control", @placeholder = "Policy StartDate Limit", @required = true })
</div>
</div>
<div class="row-fluid span12">
<div class="span4">
<p><strong>Trip End Date Limit :</strong></p>
</div>
<div class="span5">
@Html.TextBoxFor(model => model.TripEndDateLimit, "{0:dd/MM/yyyy}", new { @class = "form-control", @placeholder = "Policy EndDate Limit", @required = true })
</div>
</div>
通过 HTML 代码
<input type="text" class="form-control" id="TripStartDateLimit" name="TripStartDateLimit" value="@Model.TripStartDateLimit"/>
<input type="text" class="form-control" id="TripEndDateLimit" name="TripEndDateLimit" value="@Model.TripEndDateLimit"/>
编辑
通过单击此按钮,您可以将PolicyId
(作为示例)发送到控制器,然后您可以在那里做任何您想做的事情..!!!
<a href='../../controller/Edit?PolicyId=@Models.PolicyId'>
<span title='Edit'></span>
</a>
@Html.ActionLink("Edit","Edit", new { id = item.RequestID })
您可以找到从编辑页面发送的 PolicyId。
public ActionResult Edit(int id)
{
//Get your data from Store_procedure..
return View();
}