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 3977498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:55:51+00:00 2026-05-20T04:55:51+00:00

I have got a problem with submitting data to Post method. I have a

  • 0

I have got a problem with submitting data to Post method.

I have a class similar to this:

public class A
{
  public int Id{get; set;}
  public string Name{get; set;}
  public List<B> Bs {get; set;}
}

In the View I have a list of Bs object that I can add to the Bs property of class A without any problem. I can see the result without any problem in my Razor View as well.

The problem occurs when I post the final result to my Add Action Method to save them in my database.

When the final object is sent to my Action method the Bs property is completely empty. So what I did instead was to add that collection to a TempData dictionary and retrieved it in my Add Action method.

My question is simple why is my Bs property empty when its posted to my Edit action method ? The reason why I ask this is because in my AddBs action method I add my Bs to my Model and send it back to View and everything is find up to that point.

Edit:
@SLaks

This is the code I have in my View :

<% using (Html.BeginForm(“Create”, “A”))
{ %>
<%: Html.ValidationSummary(true) %>

            <div class="editor-label">
                <%: Html.LabelFor(model => model.Name) %>
            </div>
            <div class="editor-field">
                <%: Html.EditorFor(model => model.Name) %>
                <%: Html.ValidationMessageFor(model => model.Name) %>
            </div>

            <% if (Model.Bs.Any())
               { %>
                    <h3>B List</h3>
                    <%= Html.Telerik().Grid(Model.Bs)
                    .Name("CheckedOrders")
                    .Columns(columns =>
                    {
                        columns.Bound(d => d.Id).Width(100);
                        columns.Bound(d => d.Name).Width(300);
                    })
                    .Footer(false)
                    %>
             <% } %>

            <br />

            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    <% } %>

This is the HTML generated:

<form action="/Admin/BusinessType/Create" method="post">
    <fieldset>

        <div class="editor-label">
            <label for="Name">Name</label>
        </div>
        <div class="editor-field">
            <input class="text-box single-line" id="Name" name="Name" type="text" value="" />

            <span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span>

        </div>                 
                <div class="t-widget t-grid" id="CheckedOrders"><table cellspacing="0"><colgroup><col style="width:100px" /><col style="width:300px" /></colgroup><thead class="t-grid-header"><tr><th class="t-header" scope="col">Id</th><th class="t-last-header t-header" scope="col">Name</th></tr></thead><tbody><tr><td>2</td><td class="t-last">Heeey</td></tr><tr class="t-alt"><td>3</td><td class="t-last">Testtttt</td></tr></tbody></table></div>

        <br />
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
</form>

The Code above shows perfectly fine in my Browser, I can even see the Bs list, but when I type a Name And Click on Create, the Bs list is empty.

  • 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-05-20T04:55:51+00:00Added an answer on May 20, 2026 at 4:55 am

    I think the secret to this is in the view. I have a similar model in my app. In the view you have to format the names of the controls correctly:

    <%
    for (int i=0; i<model.Bs.Count; i++)
    {
      Html.TextBox( string.Format( "Bs[{0}].Property1OfB", i), model.Bs.Property1OfB );
      Html.TextBox( string.Format( "Bs[{0}].Property2OfB", i), model.Bs.Property2OfB );
    }
    %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a problem with my actionscript class. This is my code: package
I've got a philosophical programming problem. Let's say I have a class named Employees.
The responses I've got to this question have solved the problem I had in
I have got a problem with my codeigniter library. To transform database data into
I have a client submitting a web-request (POST) of XML data to a server.
have got a problem with do this kind of code , can't figure how
I have got this event in my page aspx.cs: public void deleteBtn_Click(object sender, CommandEventArgs
I have got the following problem since the server has safe mode turned on,
I've got a problem where I have a .co.uk domain of which I am
I have got some code to load an assembly and get all types, which

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.