I am new to MVC. I want to get "fromDate" and "ToDate" from a view. In the same view, I need three DropDownLists that are empty and hidden.
After clicking on the submit button, those DropDownLists should be visible and filled with data based on the dates picked.
But I am getting 'null reference' error on view page.
My View Page is
<h2>View Data in Database</h2>
<table><tr><td>
@using(Html.BeginForm("ViewPage1","Home"))
{
   <table><tr><td>From Date:</td>
              <td>@html.TextBoxFor(m=>m.FromDate,"{0:dd/MM/yyyy}")</td>
          </tr>
          <tr><td>To Date:</td>
              <td>@html.TextBoxFor(m=>m.ToDate,"{0:dd/MM/yyyy}")</td>
          </tr>
          <tr><td><input type="submit" Value="Show"></td>
              <td><input type="submit" Value="Show"></td>
          </tr>
   </table>
   <div id="ShowDropBoxes">
   <table>
        <tr><td>@Html.CheckBox("Production Order:", new{id="ck1"})</td>
            <td>@Html.DropDownlistFor(m=>m.ProdNo, Model.ProdOrdList, "Select Production Order")</td>
        </tr>
         <tr><td>@Html.CheckBox("Part Number:", new{id="ck2"})</td>
            <td>@Html.DropDownlistFor(m=>m.PartNo, Model.PartNoList, "Select Part Number")</td>
        </tr>
         <tr><td>@Html.CheckBox("Status:", new{id="ck3"})</td>
            <td>@Html.DropDownlistFor(m=>m.StatusTxt, Model.StatusList, "Select Status")</td>
        </tr>
   </table>
   </div>
My Model is
  public class HomeModel
  {
      public DateTime FromDate {get; set; }
      public DateTime ToDate {get; set; }
      public string ProdNo {get; set; }
      public string PartNo {get; set; }
      public int status {get; set; }
      public System.Web.Mvc.SelectList ProdNoList {get; set; }
      public System.Web.Mvc.SelectList PartNoList {get; set; }
      public System.Web.Mvc.SelectList StatusList {get; set; }
  }
Controller Is:-
  public class HomeController: Controller
  {
       Repository List_in_Repository = new Repository();
       public ActionResult ViewPage1()
       {
           return View();
       }
       [HttpPost]
       public ActionResult ViewPage(HomeModel model)
       {
             string fromdate = model.FromDate.Tostring("yyyyMMdd");
             string todate = model.ToDate.Tostring("yyyyMMdd");
             model.ProdNoList = new SelectList(List_in_Repository.GetProductionOrders(fromdate,todate));
             model.PartNoList= new SelectList(List_in_Repository.GetPartNumbers(fromdate,todate));
             model.StatusList = new SelectList(List_in_Repository.GetStatus(fromdate,todate));
            return View(model);
       }
   }
 
    