See what i am doing to do the same, Make a custom model with your relevant fields, then assign values to them in controller
, and pass this values to View
, And that's it. :)
Custom Model
public partial class QuoteParameter
{
public Nullable<System.DateTime> TripStartDateLimit { get; set; }
public Nullable<System.DateTime> TripEndDateLimit { get; set; }
public int PolicyId { get; set; }
}
Controller
public ActionResult Index()
{
QuoteParameter quote = new QuoteParameter();
quote.TripEndDateLimit = DateTime.Now;
quote.TripEndDateLimit = DateTime.Now;
quote.PolicyId = 5;
return View(quote);
}
View
@model EHIC.Models.Models.QuoteParameter
By Razor syntax
<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>
By HTML Code
<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"/>
EDIT
By Click on this button you can send the PolicyId
(as an example) to controller, and then you can do whatever you want there..!!!
<a href='../../controller/Edit?PolicyId=@Models.PolicyId'>
<span title='Edit'></span>
</a>
@Html.ActionLink("Edit","Edit", new { id = item.RequestID })
You can find the PolicyId which you sent from the Edit Page..
public ActionResult Edit(int id)
{
//Get your data from Store_procedure..
return View();
}