I have created a web application in mvc3 and created two partial views one having controls like dropdownlist. second having webgrid which shows data from database.
partialview1.cshtml
@model Mapping.Models.SecurityIdentifierMapping
@using (Html.BeginForm("Mapping", "Home"))
{
@Html.DropDownList("SecurityID", Model.PricingSecurityID, "-- Select SecurityID --")
<br />
@Html.DropDownList("CUSIPID", Model.PricingSecurityID, "-- Select CUSIPID --")
<br />
<button type="submit">Map</button>
}
partialview2.cshtml
@model IEnumerable<Mapping.Models.SecurityIdentifierMapping>
@{
ViewBag.Title = "Mapping";
WebGrid grid = null;
if (Model.Count() > 0 ){
grid = new WebGrid(source: Model,
defaultSort: "Id",
canPage: true,
canSort: true,
rowsPerPage:20);
}
}
<h2>Mapping</h2>
@if (grid != null)
{
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("", header: null, format: @<text>@Html.ActionLink("Edit", "Edit", new { id = (int)item.id }) @Html.ActionLink("Delete", "Delete", new { id = (int)item.id })</text>),
grid.Column("PricingSecurityID"),
grid.Column("CUSIP")
)
)
}
<br />
<p>
@Html.ActionLink("Back", "Index")
</p>
in index.cshtml
<div>
@Html.Partial("_ControlsPartial",)
</div>
<div>
@Html.Partial("_WebGridPartial")
</div>
HomeController.cs
public ActionResult Index()
{
SecurityIdentifierMapping objModel = new SecurityIdentifierMapping();
objModel.PricingSecurityID = objRepository.GetPricingSecurityID();
objModel.CUSIP = objRepository.GetCUSIP();
return View(objModel);
}
如何用同样的指数显示网格和人口下降?
getting error :( what should be 2nd parameter inside @Html.Partial() so that both grid and control works fine on same page.?