I'm kind of new to MVC and I need help figuring this issue out:

I have this method on a controller:

        public List<BillingModel> DeleteFOP(List<BillingModel> FOPList)
            /*If FOPList is null we instantiate it to a type of BillingModel List
            Effectively avoiding an exception to occur*/
            if (FOPList == null)
                FOPList = new List<BillingModel>();
            {   //remove indexed(FOP) item if the checkbox is checked.
                for (int i = FOPList.Count - 1; i >= 0; i--)
                    if (FOPList[i].CheckBox == true)

           return FOPList;

Which is triggered after they click on a Delete submit button

and stepping through the iteration and index the item removed and item remaining seem correct, this populates the < td >s in the View

@for (int i = 0; i < Model.editBillingFOPList.Count;i++ )
                           <td>@Html.TextBox("FOPList[" + @i + "].Fund", 
                            <td>@Html.TextBox("FOPList[" + @i + "].ORGN", 
                            <td>@Html.TextBox("FOPList[" + @i + "].Program", 
                            <td>@Html.TextBox("FOPList[" + @i + "].Percentage", 
                            <td>@Html.CheckBox("FOPList[" + @i + "].CheckBox", 
                                                Model.editBillingFOPList[i].CheckBox, new { @checked = false })</td>

and stepping through this still displays the right item marked for deletion, e.g.:

item 1: Field1 Field2 Field3 Field4 1 √

item 2: Field1 Field2 Field3 Field4 2

Item 2 should remain when my view is rendered and after debugging it seems as though Item 2 will be displayed but then the view renders and the item remaining is Item 1 , and Item 2 gets deleted- any advise will be greatly appreciated !

Related posts

Recent Viewed