Hey everyone,

I have this problem. I need to access data that the user inputs via the <input /> statement during the controller method.

Here's my code, maybe this will make it more clear:

// client side
@using (Html.BeginForm())
    if (competitorList.Count > 0 && eventList.Count > 0)
        foreach (Event evt in eventList)
            <th>New Score</th>
            @foreach (Results res in resultList)
                if (res.EventID == evt.id)
                    string competitorName = Person.getUserByEmail(res.CompetitorEmail).FirstName + Person.getUserByEmail(res.CompetitorEmail).LastName;

                        <td><form action="EventResults"><input type="text" name="score" id="score" /></form></td>
                        <td>@Html.ActionLink("Update", "UpdateResults", "Competition", new { compId = evt.competitionId, evtId = res.EventID, email = res.CompetitorEmail }, null)</td>
            <hr />
        <p>There are currently no competitors invited to participate</p>

// controller
public ActionResult UpdateResults(FormCollection form, int compId, int evtId, string email)
            //////     this returns 0.0     /////
            double score = Convert.ToDouble(form["score"]);

            BINC.Models.Results.UpdateResults(evtId, email, score);

            List<Event> CompetitionEvents = Event.getEventsByCompetitionId(compId);
            ViewBag.CompetitionEvents = CompetitionEvents;

            List<Competitor> Competitors = Competitor.getCompetitors(compId);
            ViewBag.Competitors = Competitors;

            List<Results> Results = Competition.getCompetitorResultsPairings(CompetitionEvents, Competitors);
            ViewBag.Results = Results;

            ViewBag.Competition = Competition.getCompetitionById(compId);

            return View("EventResults");

Can someone give me a hand?

5 Years
Discussion Span
Last Post by vsmash

You Cannot open a form within a form:
your code says, "@using (Html.BeginForm())" then later says, "<form...."
Get rid of your secoond form and use @Html.EditorFor(res.Score)


Start a new form for each iteration and get rid of the encapsulating @using(Html.BeginForm....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.