Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8330943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:16:31+00:00 2026-06-09T02:16:31+00:00

I have @Ajax.BeginForm in each row of Table, When I make post request using

  • 0

I have @Ajax.BeginForm in each row of Table, When I make post request using that form then Model is null except first row.

Only first form is working, second and so on forms are not working…. I have used Form ID unique for all.

Probably, because of I am using IList and for loops,

AND first form has controls name like [0].lstMatches[4].match_set_name
and second,third,…. form has control name like [n].lstMatches[4].match_set_name

and IList can provides the model only for First one, [0].lstMatches[4].match_set_name

Here is my View structure

  @model IList<QIOnlineMVC3.Models.TravelAdsRulesMatchsGroups>
@{
ViewBag.Title = "Business Rule Travel Ads";
ViewBag.Layout = "_Layout2";
 }

 <table id="PageSortTable" class="travelads_business_rules" cellspacing="0">
<tr></tr>
 <tbody>
@for (var i = 0; i < Model.Count; i++)
    {
<tr class="minimised" id='trMinimised@(Model[i].id)'>
            <td colspan="13">
                @using (Ajax.BeginForm("_SaveGroupMatchs", null, new AjaxOptions { OnSuccess = "onSuccess", UpdateTargetId = "msgResult", LoadingElementId = "msgLoading", HttpMethod = "Post" }, new { @id = "SaveForm" + Model[i].id.ToString() }))
                {  
 <div class="detail">
  <div class="table_header">
                        <span class="col_a">Group</span> <span class="col_b">Group Scope</span> <span class="col_c">
                            Seq</span> <span class="col_d">&nbsp;</span> <span class="col_e">ID</span> <span
                                class="col_f">Match Location</span> <span class="col_g">Target Field</span>
                        <span class="col_h">Match Type</span> <span class="col_i">Set Name</span>
                    </div>
                    <!-- Loop for matches -->
                    <!-- start GROUP -->
                    <div class="group" id="Group_rule_@(Model[i].id)">

                       @Html.HiddenFor(model => @Model[i].id)
                       @Html.HiddenFor(model => @Model[i].ad_rule_name)
                       @Html.HiddenFor(model => @Model[i].ad_rule_desc)
                       @Html.HiddenFor(model => @Model[i].business)
                       @Html.HiddenFor(model => @Model[i].ad_region)
                       @Html.HiddenFor(model => @Model[i].ad_form)
                       @Html.HiddenFor(model => @Model[i].ad_company)
                       @Html.HiddenFor(model => @Model[i].ad_team)
                       @Html.HiddenFor(model => @Model[i].ad_language)
                       @Html.HiddenFor(model => @Model[i].ad_media_id)
                       @Html.HiddenFor(model => @Model[i].ad_insert_loc)
                       @Html.HiddenFor(model => @Model[i].ad_priority)
                       @Html.HiddenFor(model => @Model[i].access)
                       @Html.HiddenFor(model => @Model[i].deployment)


                        @for (var j = 0; j < Model[i].lstMatches.Count; j++)
                        {
                            <div id="rule@(Model[i].id)_divRuleGroup_@(Model[i].lstMatches[j].match_group_num)">
                             @Html.HiddenFor(model => Model[i].lstMatches[j].match_rule_id)
                             @Html.HiddenFor(model => Model[i].lstMatches[j].match_id)
                             @Html.HiddenFor(model => Model[i].lstMatches[j].match_group_num)
                             @Html.HiddenFor(model => Model[i].lstMatches[j].match_rule_type)
                             @Html.HiddenFor(model => Model[i].lstMatches[j].created)
                             @Html.HiddenFor(model => Model[i].lstMatches[j].access)
                            <header id="header_rule_Group"><span class="col_a">
                             @if (Model[i].lstMatches[j].Position == "First")
                             {
                                @(Model[i].lstMatches[j].match_group_num) 
                             } </span>
                            <span class="col_b">
                                            @if (Model[i].lstMatches[j].Position == "First")
                                            {
                                            @Html.DropDownListFor(model => Model[i].lstMatches[j].match_group_scope, new SelectList((List<QIOnlineMVC3.Helpers.clsGroupScope>)QIOnlineMVC3.Helpers.General.GetALLGroupScope(), "GroupScope", "GroupScope", Model[i].lstMatches[j].match_group_scope))
                                            }
                                            else
                                            {
                                                @Html.HiddenFor(model => Model[i].lstMatches[j].match_group_scope)
                                            }
                                          </span></header>
                            <div class="match">
                                <span class="col_c">@(Model[i].lstMatches[j].match_group_seq) @Html.HiddenFor(model => Model[i].lstMatches[j].match_group_seq) </span> 
                                <span class="col_d">
                                <a href="@(Url.Action("DeleteMatch", new { id = Model[i].lstMatches[j].match_id }))">
                                    <img alt="Delete" src="../../Content/Images/delete-icon.png" width="17" height="17" border="0" title="delete" /></a> 

                                        </span><span class="col_e">@(Model[i].lstMatches[j].match_id)
                                        </span><span class="col_f">
                                            @Html.DropDownListFor(model => Model[i].lstMatches[j].match_loc, new SelectList((List<QIOnlineMVC3.Helpers.clsMatchLocations>)QIOnlineMVC3.Helpers.General.GetALLMatchLocations(), "MatchLocations", "MatchLocations", Model[i].lstMatches[j].match_loc))
                                        </span><span class="col_g">
                                            @Html.DropDownListFor(model => Model[i].lstMatches[j].match_target_field, new SelectList((List<QIOnlineMVC3.Helpers.clsTargetField>)QIOnlineMVC3.Helpers.General.GetALTargetField(), "TargetField", "TargetField", Model[i].lstMatches[j].match_target_field))
                                        </span><span class="col_h">
                                            @Html.DropDownListFor(model => Model[i].lstMatches[j].match_type, new SelectList((List<QIOnlineMVC3.Helpers.clsMatchType>)QIOnlineMVC3.Helpers.General.GetALLMatchType(), "MatchTypeID", "MatchType", Model[i].lstMatches[j].match_type))
                                        </span><span class="col_i">
                                            @Html.TextBoxFor(model => Model[i].lstMatches[j].match_set_name, new { @value = Model[i].lstMatches[j].match_set_name, @class = "clsauto" })
                                            </span></div>
                            </div>


                                       if (Model[i].lstMatches[j].Last == "Last")
                                       {
                            <div id="Group_rule_@(Model[i].id)_@(Model[i].lstMatches[j].match_group_num)"></div>
                            <!-- end MATCH -->
                            <div class="new">
                                @Ajax.ImageWithTextActionLink("<img src=\"../../Content/Images/new-icon.png\" width=\"17\" height=\"17\" border=\"0\" alt=\"New Match\" />New Match", "NewMatch", new { ruleid = Model[i].id, groupid = Model[i].lstMatches[j].match_group_num }, new AjaxOptions { UpdateTargetId = "Group_rule_" + Model[i].id.ToString() + "_" + Model[i].lstMatches[j].match_group_num, InsertionMode = InsertionMode.InsertBefore, HttpMethod = "Get", LoadingElementId = "msgLoading" })
                            </div>
                                       }

                        }

                    </div>
                    <!-- end MATCH GROUP -->
                    <!-- END Loop of Matches -->
                    <div class="new new_group">
                        @Ajax.ImageWithTextActionLink("<img src=\"../../Content/Images/new-icon.png\" width=\"17\" height=\"17\" border=\"0\" alt=\"New Group\" />New Group</a>", "NewGroup", new { ruleid = Model[i].id }, new AjaxOptions { UpdateTargetId = "Group_rule_" + Model[i].id.ToString(), InsertionMode = InsertionMode.InsertAfter, HttpMethod = "Get", LoadingElementId = "msgLoading" })
                        <div class="delete_group">
                            Delete Group ID:
                            <input type="text" id='txtdeleteGroupNo_@(Model[i].id)' />
                            <input type="submit" id='btnDeleteGroup_@(Model[i].id)' value="Delete Group" class="btn btn_delete" style="float: none;" onclick="return DeleteGroup(this);" />
                        </div>
                    </div>
                    <div id="divNewGroup">
                    </div>
                    <div class="btn_row">
                        <input type="reset" name="reset" class="btn" value="Cancel" onclick='DoExpandCollapsh("trMinimised@( Model[i].id)","main_collapsed@( Model[i].id)","main_expanded@( Model[i].id)")'/>
                        <input type="submit" name="btnSave" class="btn" value="Save" />
                        <a href="@(Url.Action("DeleteTravelAdsRule", new { id = Model[i].id }))" class="btn btn_delete">
                            Delete Rule</a>
                    </div>
                </div>
                }

            </td>
        </tr>

    }
</tbody>

Here is my Controller

    [Authorize]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult _SaveGroupMatchs(IList<TravelAdsRulesMatchsGroups> mm)
    {
        try
        {
            if (mm != null & mm.Count > 0)
            {

                foreach (var item in mm)
                {
                    List<MatchModel> LMM = item.lstMatches.ToList();
                    List<MatchModel> LMMUpdate = LMM.Where(t => t.match_id != 0).ToList();
                    //update 
                    foreach (var mmupdate in LMMUpdate)
                    {
                        UpdateMatch(mmupdate);
                    }
                    List<MatchModel> LMMSave = LMM.Where(t => t.match_id == 0).ToList();
                    //save
                    foreach (var itemSave in LMMSave)
                    {
                        itemSave.access = item.access;
                        itemSave.deployment = item.deployment;
                        itemSave.match_deployment = item.deployment;
                        CreateMatch(itemSave);
                    }
                }
            }
        }
        catch { Content("Problem due to Error"); }

        return Content("Record Saved Successfully!");
    }

I am not getting IList for second and So on rows…

How can I get it, any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:16:33+00:00Added an answer on June 9, 2026 at 2:16 am

    Well I don’t really understand what you’d like to do.

    • If you’d like to save the wole list of TravelAdsRulesMatchsGroups
      Use only ONE form which calls your _SaveGroupMatchs action method

    • If you’d like to save only one TravelAdsRulesMatchsGroups (one submit button for each record),
      keep using one form per row and change the action of your controller to

      public ActionResult _SaveGroupMatchs(TravelAdsRulesMatchsGroups mm)
      

      then adapt your action method to handle the recording of an instance of TravelAdsRulesMatchsGroups

      And, in your View, don’t use

      @Html.HiddenFor(model => model[i].Id)
      

      If you use this syntax, the rendered Html will be <input ... name="[i].Id" />
      (eg. <input ... name="[2].Id" />)

      The model binder uses the name to fill your model’s properties

      Instead, use

      @* for your TravelAdsRulesMatchsGroups properties *@
      @Html.Hidden("id", Model[i].id)
      @* ... and so on ...*@
      
      
      @* for the lstMatches property, which is a list of MatchModel *@
      @for (var j = 0; j < Model[i].lstMatches.Count; j++)
      {
          @Html.Hidden("lstMatches[" + j.ToString() + "].match_rule_id", Model[i].lstMatches[j].match_rule_id)
          @* ... and so on ...*@
      }
      

    Note : be carefull, you cannot use nested Html forms !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I have a form created using Ajax.BeginForm() <% using (Ajax.BeginForm(UpdateCompanyShop, CompanyShop, FormMethod.Post, new AjaxOptions
I have an table and needed Ajax form for each row so this is
I have an Ajax Form that looks like this: <% using (Ajax.BeginForm(Update, new AjaxOptions
I have an ajax form like so: <% using (Ajax.BeginForm(Comments, Comments, null, new AjaxOptions
I have form in my page, I am using ajax.beginform(). Inside this form I
I have ajax request that do 3 missions: Save Model (DB) Send Email Give
I have an Ajax form : <%using (Ajax.BeginForm(...)){%> ... <input id=btn1 type=submit value=OK1/> <input
i have a jquery Dialog in a partial view: @model JQueryDialogPoc.Models.FeedBack @using (Ajax.BeginForm(GiveFeedback, Home,
I have a simple form created using Ajax.BeginForm : <% using (Ajax.BeginForm(Update, Description, new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.