Below link i followed, but i do not have idea to pass date parameter from view to controller.
below is my model class
public class CustomerMV
{
public int CustomerID { get; set; }
public string CustomerName { get; set; }
public string Name { get; set; }
public string ContentType { get; set; }
public byte[] Data { get; set; }
public string AName { get; set; }
public string I_Status { get; set; }
public Nullable<int> EmpID { get; set; }
public string C_Address { get; set; }
[DataType(DataType.Date, ErrorMessage = "Date only")]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> C_Date { get; set; }
}
Controller
public class CustomerController : Controller
{
SilverProductionEntities DB = new SilverProductionEntities();
// GET: Customer
public ActionResult CustomerList()
{
var list = new List<CustomerMV>();
var customers = DB.Customers.ToList().Where(t => t.Data != null );
//var tblAccountControls = DB.tblAccountControls.Include(t => t.tblBranch).Include(t => t.tblCompany).Include(t => t.tblUser);
foreach (var customer in customers)
{
list.Add(new CustomerMV { CustomerID = customer.CustomerID, CustomerName = customer.CustomerName,Data=customer.Data
});
}
return View(list);
}
}
View
@model IEnumerable<ERP_APP.Models.CustomerMV>
@{
}
<div class="card">
<div class="card-header">
<div class="text-sm">
<div class="card-title">Item List</div>
</div>
</div>
<div class="card-body">
@Html.ActionLink("Create Customer", "CreaterCustomer", null, new { @class = "btn btn-primary" })
<hr />
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-md-8">
@Html.TextBox("start", null, new { htmlAttributes = new { @class = "form-control", @id = "datetimepicker1" } })
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-md-8">
@Html.TextBox("end", null, new { @class = "form-control datepicker" })
</div>
</div>
<div class="form-group-sm">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" /> <span> </span>
</div>
</div>
</div>
<table class="table table-striped my-4 w-100" id="datatable2">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.CustomerID)
</th>
<th>
@Html.DisplayNameFor(model => model.CustomerName)
</th>
<th>
@Html.DisplayNameFor(model => model.Data)
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CustomerID)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerName)
</td>
<td>
<img src="data:image/jpeg;base64,@(Convert.ToBase64String(item.Data))" width="50" height="30">
</td>
<td>
@Html.ActionLink("Edit", "EditItem", new { customerid = item.CustomerID }, new { @class = "btn btn-warning" }) |
@Html.ActionLink("Delete", "Delete", new { }, new { @class = "btn btn-danger" })
</td>
</tr>
}
</tbody>
</table>
</div>
</div>