@model List<Html_Grid_MVC.Models.Customers>
@{
ViewBag.Title = "Display Data in Gridmvc based on Dropdownlist selected value in MVC Razor";
}
@using GridMvc.Html
<h2>Index</h2>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<link href="@Url.Content("~/Content/Gridmvc.css")" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/gridmvc.min.js")"></script>
<script src="~/bootstrap/js/bootstrap.min.js"></script>
<link href="~/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/Site.css" rel="stylesheet" />
<div class="container">
<div style="margin-top: 10px"></div>
<div class="logo col-sm-12 text-center col-md-12 ">
</div>
<div class="clearfix"></div>
@using (Html.BeginForm("Index", "HTMLGrid_", FormMethod.Post, new { @name = "Form1" }))
{
<fieldset>
<legend class="legend">All Customers Detail</legend>
Address <select id="ddlType" class="form-control" onchange="OnChange()" name="ddlType">
<option value="0">Select</option>
<option value="Russia">Russia</option>
<option value="Canada">Canada</option>
<option value="China">China</option>
<option value="United States">United States</option>
</select>
<div style="margin-top: 5px"></div>
<div class="test" style="overflow: scroll; height: auto; width: 600px">
<div style="width: 600px">
<div class="panel">
<div class="panel-body">
@Html.Grid(Model).Columns(columns =>
{
columns.Add(c => c.customerID).Titled("CustomerID");
columns.Add(c => c.FirstName).Titled("FirstName");
columns.Add(c => c.LastName).Titled("LastName");
columns.Add(c => c.CreatedDate).Titled("CreatedDate").Format("{0:dd/MM/yyyy}");
columns.Add(c => c.Address).Titled("Address");
}).WithPaging(10);
</div>
</div>
</div>
</div>
</fieldset>
}
<script>
function OnChange() {
document.forms["Form1"].submit();
}
window.onload = function () {
$("#ddlType").val("@ViewBag.Selected")
}
</script>
</div>