-3

I have a View as mentioned below:

@model Hello.Web.Models.ClaimDataViewModel
@{
    ViewBag.Title = "Index";
}

 @using (Ajax.BeginForm("Index", "Search", new AjaxOptions { UpdateTargetId = "divWebGrid", InsertionMode = InsertionMode.Replace, LoadingElementId = "imgLoad" }))
{ 

//some code

}
@if (Model != null && Model.ClaimDataViewModelList != null)
{
    <div class="panel panel-default" id="divWebGrid">
        <div class="panel-heading panel-heading-sm" style="padding:5px 0px 0px 5px;" >
            <h5 class="panel-title"><b>Search Results:</b></h5>
        </div>
        <div class="panel-body">
            @{Html.RenderPartial("_Index", Model.ClaimDataViewModelList);}
        </div>
    </div>
}

And then I have a partial view:

    @model IEnumerable<Hello.Web.Models.ClaimDataViewModel>

@if (Model.Count() > 0)
{

    <table id="tblSearchRecords" class="table table-hover table-condensed">
        <thead>
            <tr>                
                <th style="visibility:hidden;"></th>
                <th>Claim#</th>
                <th>Status</th>
                <th>Due Date</th>
                <th>Claimant</th>                
                <th>Insured Name</th>
                <th>Claim Handler</th>
                <th style="text-align:center;">Full Value</th>
                <th style="text-align:center;">Opt Out</th>
                <th style="text-align:center;">Reassign</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @for (int i = 0; i < Model.Count(); i++ )
            {
                <tr>                    
                    <td>@Html.RadioButton("rbCheck", new { ClaimDataId = Model.ElementAt(i).ClaimDataId })</td>
                    <td>@Html.ActionLink(Model.ElementAt(i).ClaimNum + "-" + Model.ElementAt(i).LineSuffix, "")</td>
                    <td>                        
                        @if (Model.ElementAt(i).MRPLineStatus == "PENDG")
                        { <p>Pending</p> }
                        else if (Model.ElementAt(i).MRPLineStatus == "INPRG")
                        { <p>In Progress</p> }
                        else if (Model.ElementAt(i).MRPLineStatus == "COMPL")
                        { <p>Complete</p> }
                        else if (Model.ElementAt(i).MRPLineStatus == "OPOUT")
                        { <p>Opt Out</p> }
                    </td>
                    <td>@Html.DisplayFor(m => m.ElementAt(i).DueDate)</td>
                    <td>@Html.DisplayFor(m => m.ElementAt(i).ClaimantName)</td>                    
                    <td>@Html.DisplayFor(m => m.ElementAt(i).InsuredName)</td>
                    <td>@Html.DisplayFor(m => m.ElementAt(i).ClaimHandlerName)</td>
                    <td style="text-align:right;">@Html.DisplayFor(m => m.ElementAt(i).FullValueAmt)</td>
                    <td style="text-align:center;">@Html.CheckBoxFor(m => m.ElementAt(i).IsOptOut)</td>
                    <td style="text-align:center;">@Html.CheckBoxFor(m => m.ElementAt(i).IsReassigned)</td>
                    <td>
                        @if (Model.ElementAt(i).DueDate < DateTime.Now)
                        {
                        <span class="glyphicon glyphicon-alert" style="color:red"></span>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>

    <hr />
    <div class="row">
        <div class="col-sm-3">
            <div class="input-group input-group-sm" style="max-width: 250px;">
                <span class="input-group-addon">Reassign To:</span>
                @Html.DropDownList("ddlReassignTo", (IEnumerable<SelectListItem>)ViewBag.ReviewerList, new { @class = "form-control" })
            </div>
        </div>
        <div class="col-sm-5">
            <div class="input-group input-group-sm" style="width: 200%;">
                <span class="input-group-addon">Opt Out Reason:</span>
                <input type="text" class="form-control" />
            </div>
        </div>        
    </div>

    <div class="row">
                <div class="col-sm-offset-10 col-sm-1">
            @*<button type="submit" class="btn btn-sm btn-primary pull-right"><span class="glyphicon glyphicon-floppy-save">&nbsp</span>Save</button>*@

            @Html.ActionLink("Save", "SaveUpdatedClaims", "Search", new { }, new { @id = "btnTEST", @class = "btn btn-sm btn-primary pull-right" })
        </div>
        <div class="col-sm-1">
            @*<button type="submit" class="btn btn-sm btn-primary" id="btnOpenMr"><span class="glyphicon glyphicon-eye-open">&nbsp</span>Open MR</button>*@

            @Html.ActionLink("Open MR", "RedirectToReview", "Search", new { }, new { @id = "btnOpenMr", @class = "btn btn-sm btn-primary pull-right" })
        </div>
    </div>

}
else
{
    <div class="alert alert-warning"><b>No records found !</b></div>
}

Now I am getting a null in my model of my action method when i click on the "Save" button on my partial view.

can anyone tell me whats wrong here?

UPDATE:
Below is the action method:

    [HttpPost]
    public ActionResult SaveUpdatedClaims(IEnumerable<ClaimDataViewModel> model)
    {
        return View();
    }
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
  • You don't have a 'save' button. Just a link that does a redirect to a GET method. You don't even have a form. And if you had both, it would still not work because you cannot use `.ElementAt()` to generate your form controls –  Sep 09 '16 at 10:34
  • decorate your code by a form tag – Monah Sep 09 '16 at 10:34
  • @StephenMuecke: I had used a button to submit . I even wrapped the partial view with a "form" .Moreover, i was using foreach loop to iterate. But nothing worked. – Bhupinder Singh Sep 09 '16 at 10:38
  • 1
    Because you cannot use a `foreach` loop. And you cannot use `.ElementAt()`. Refer [this answer](http://stackoverflow.com/questions/30094047/html-table-to-ado-net-datatable/30094943#30094943). –  Sep 09 '16 at 10:40
  • That Worked !!!....now i am using IList. Thanks @StephenMuecke – Bhupinder Singh Sep 09 '16 at 10:55

1 Answers1

0

Because your model is list type @model IEnumerable<Hello.Web.Models.ClaimDataViewModel> and you accepting object type Hello.Web.Models.ClaimDataViewModel in action.

And also form tag is missing