I do have a textbox and a submit button. All I have to do is to get the records based on the date provided and when a get request is made I just want to display a textbox and button. For Post request I want to check the date matches with the record and want to display the data within same view. How is that possible. I am having the view as
@model IEnumerable<ShopOnline.Models.Order>
<script type="text/javascript">
$(function () {
$("#Date").datepicker({dateFormat:"dd/mm/yy"});
});
</script>
@using(Html.BeginForm())
{
<table>
<tr>
<td>Enter Date</td>
<td>@Html.TextBox("Date")</td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
}
<table border="1">
<thead>
<tr>
<td>Order</td>
<td>Product Name</td>
<td>Quantity</td>
<td>Amount</td>
<td>Price</td>
<td>Date</td>
</tr>
</thead>
<tbody>
@foreach(var item in Model)
{
<tr>
<td>Select Date</td>
<td>@item.Order_Id</td>
<td>@item.Product_Name</td>
<td>@item.Quantity</td>
<td>@item.Amount</td>
<td>@item.Order_Date</td>
</tr>
}
</tbody>
Here is the controller Action Method
public ActionResult Admin()
{
return View(db.Orders.ToList());
}
[HttpPost]
public ActionResult Admin(DateTime Date)
{
var record = db.Orders.Where(x => x.Order_Date ==Date).ToList();
return View(record);
}
Now here the problem is I will get all the records displayed if I perform GET Request and I only want to display a textbox and button on GET request and while if I perform a POST Request I want to get list of records in the same view with a textbox and button. So can Partial View be applied here and how will that work