Hello,
Please help to understand how pass view values to controller as parameters on clicking of filter button below is my code sample
View
- @model UniPro.Web.Models.EmployeeDashboardModel
- @{
- ViewBag.Title = "EmployeeList";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
LocationList
- @using (Html.BeginForm("filterLOV", "EmployeeLocationList", FormMethod.Get))
- {
- class="contentbox">
class
="contentboxheading">- @ViewBag.Title
class="contentbox_innercontent">"100%">
- @Html.Hidden("ID",Model.EmpListLOV,new { id = "empID"})
- ="highlightlabel">ID
- @Html.DevExpress().TextBox(
- txtsetting =>
- {
- txtsetting.Name = "txtemployeeID";
- txtsetting.ClientEnabled = true;
- txtsetting.Width = System.Web.UI.WebControls.Unit.Pixel(150);
- txtsetting.Height = System.Web.UI.WebControls.Unit.Pixel(25);
- txtsetting.Properties.MaxLength = 50;
- ().value); }";
- }).GetHtml()
- ="highlightlabel">Name
- @Html.Hidden("Name", Model.EmpListLOV, new { id = "hiddenName" })
- @Html.DevExpress().TextBox(
- txtsetting =>
- {
- txtsetting.Name = "txtemployeeName";
- txtsetting.ClientEnabled = true;
- txtsetting.Width = System.Web.UI.WebControls.Unit.Pixel(150);
- txtsetting.Height = System.Web.UI.WebControls.Unit.Pixel(25);
- txtsetting.Properties.MaxLength = 50;
- }).GetHtml()
- ="highlightlabel">Age
- @Html.Hidden("Age", Model.EmpListLOV, new { id = "hiddenAge" })
- @Html.DevExpress().TextBox(
- txtsetting =>
- {
- txtsetting.Name = "txtemployeeAge";
- txtsetting.ClientEnabled = true;
- txtsetting.Width = System.Web.UI.WebControls.Unit.Pixel(150);
- txtsetting.Height = System.Web.UI.WebControls.Unit.Pixel(25);
- txtsetting.Properties.MaxLength = 50;
- }).GetHtml()
- ="highlightlabel">Maritial Status
- @Html.Hidden("EMPMaritial_Status", Model.maritial_StatusList, new { id = "hiddenstatus" })
- @Html.DevExpress().ComboBox(
- settings =>
- {
- settings.Name = "drostatus";
- settings.Width = System.Web.UI.WebControls.Unit.Pixel(100);
- //settings.Style.Add("width", "85");
- settings.Properties.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDownList;
- settings.Properties.TextFormatString = "{0}";
- settings.Properties.ValueType = typeof(string);
- settings.Properties.ValueField = "ID";
- settings.Properties.TextField = "EMPMaritial_Status";
- }).BindList(Model.maritial_StatusList).GetHtml()
- ="highlightlabel">Location
- @Html.Hidden("EMP_Location", Model.LocationLOV, new { id = "hiddenLocation" })
- @Html.DevExpress().ComboBox(
- settings =>
- {
- settings.Name = "droLocation";
- settings.Width = System.Web.UI.WebControls.Unit.Pixel(100);
- //settings.Style.Add("width", "85");
- settings.Properties.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDownList;
- settings.Properties.TextFormatString = "{0}";
- settings.Properties.ValueType = typeof(string);
- settings.Properties.ValueField = "ID";
- settings.Properties.TextField = "EMP_Location";
- }).BindList(Model.LocationLOV).GetHtml()
- "button" name="btnSearch" id="btnFilter" value="Apply Filter" class="buttoncss" title="Click for Search" style="width: 100px;" />
"center" style="margin-top:3%" id="container">- @Html.Partial("EmplyeeDemoGridPartial", Model.EmpListLOV)
- }
controller
- public ActionResult FilterLOV(int? txtemployeeID, string txtemployeeName, int? txtemployeeAge,int? droLocation)
- {
- List
empSearch = new List (); - IEmployeeDemoBusinessService empSearchBS = new EmployeeDemoBusinessService();
- empSearch = empSearchBS.GetEmployeeByFilter(txtemployeeID, txtemployeeName,txtemployeeAge, droLocation);
- return PartialView("EmplyeeDemoGridPartial", empSearch);
- }
Model
- public class EmployeeDashboardModel
- {
- public List
EmpListLOV { get; set; } - public List
LocationLOV{ get;set;} - public List
maritial_StatusList { get; set; } - }
Firstly i was using ajax call to pass the data from the view to controller but i want to do the same with model binding.
Please suggest.
Ritendra MallPosted Aug 21, 2019, 1:54 AM
Sonu GuptaPosted Aug 21, 2019, 1:36 AM