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

  • SEARCH
  • Home
  • 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 6850345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:47+00:00 2026-05-27T01:06:47+00:00

this is my controller: public ActionResult Create() { Number newNumber = new Number(); return

  • 0

this is my controller:

public ActionResult Create() {
            Number newNumber = new Number();
        return View(newNumber);
    }

and View :

@model PhoneBook.Models.Number
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<script src="../../Scripts/jQuery.AddNewNumber.js" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Contact.Id)
<fieldset>
<legend>Number</legend>
<div class="TargetElements">
    <div class="editor-label">
        @Html.LabelFor(model => model.PhoneNumber)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.PhoneNumber)
        @Html.ValidationMessageFor(model => model.PhoneNumber)
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.NumberKind)
    </div>
    <div class="editor-field">
    @Html.DropDownListFor(model => model.NumberKind.Title, NumberKinds)
    </div>
</div>
<p>
    <input class="AddNew" value="Add New" type="button" /></p>
<p>
    <input type="submit" value="Create" />
</p>
</fieldset>
}

By press AddNew button (use jQuery AddNewNumber.js) new input+DropDown Added to form in client side. this is script:

$(document).ready(function () {
$('.AddNew').click(function () {
    var targetcloneelements = $(".TargetElements:first").clone();
    targetcloneelements.find('input').val('');
    targetcloneelements.insertAfter('.TargetElements:last');
});
});

This way(Add new) is very usual, All of us can see that in many sites (So that must have a solution), But there is a problem in retrieve values. When I have one entry element(include input+DropDown) I can retrieve values like the following in post of my controller:

[HttpPost]
    public ActionResult Create(Number NewNumber, FormCollection collection) {
            db.Numbers.Add(NewNumber);
            db.SaveChanges();
            return RedirectToAction("Index")
}

I read this articles : 1 , 2 , 3 but none of them haven’t any solution for fly mode add entries, when I know the numbers of entity it can be possible but in fly mode it can be 1 or 1000

So, is there any way to retrieve values and add them to DataBase?

Edit:

I find the values in FormCollection but yet I don’t know how extract them from collection? This is a picture of the Collection values in breakponit of binding

Pic

Edit2:

Find to retrieve all values: (every element has a key that seen in above pic)

string[] PhoneNumbers = collection.GetValues("PhoneNumber");
  • 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-27T01:06:48+00:00Added an answer on May 27, 2026 at 1:06 am

    every element has a key so you can use this for example:

    string[] PhoneNumbers = collection.GetValues("PhoneNumber");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my controller: public ActionResult Create() { Number newNumber = new Number(); return
This is my view: @model PhoneBook.Models.Number @{ ViewBag.Title = Create; } <h2>Create</h2> <script src=../../Scripts/jQuery.AddNewNumber.js
With this controller method: - [AcceptVerbs(HttpVerbs.Post)] public ViewResult Contact(Contact contactMessage) { return View(); }
i have this controller: public ActionResult Novo() { var products = context.Product.Select(x => new
My controller looks like this: public class PortefeuilleController : Controller { public ActionResult Create()
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
I have the following code in my Simulacion controller: [Authorize] public ActionResult Create() {
I try to create a product detail (accommodation details) view based on this controller
I've this controller public class AdminController : Controller { private IAdministratorService _administratorService; public AdminController(IAdministratorService
I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public

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.