Hey everyone,

I'm having some problems with my code and was hoping someone could give me a hand. Here's the snippet I'm working with:

[Authorize]
        public ActionResult EventResults(int id)
        {
            List<Event> CompetitionEvents = Event.getEventsByCompetitionId(id);
            ViewBag.CompetitionEvents = CompetitionEvents;

            List<Person> Competitors = Competition.getCompetitorsByCompetitionID(id);
            ViewBag.Competitors = Competitors;

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

            ViewBag.OrganizerEmail = Competition.getCompetitionById(id).OrganizerEmail;

            return View();
        }



@model BINC.Models.Results
@using BINC.Models;

@{
    var eventList = ViewBag.CompetitionEvents as List<Event>;
    var competitorList = ViewBag.Competitors as List<Person>;
    var resultList = ViewBag.Results as List<Results>;
}

<h2></h2>

<p>Results:</p>
    @using (Html.BeginForm())
       {
            foreach (var evt in eventList)
            {
                <fieldset>
                    <legend>@evt.activity.Name</legend>

                   <p>Event Description:  @evt.activity.Description</p>
                   @foreach (var competitor in competitorList)
                   {
                       foreach (var result in resultList)
                       {
                           if (result.EventID == evt.id && result.CompetitorEmail == competitor.Email)
                           {
                               <p>Competitor:  @competitor.FirstName @competitor.LastName</p>
                               <p>Score:  @result.Score</p>

                               if (ViewBag.OrganizerEmail.Equals(@User.Identity.Name))
                               {
                                    @Html.LabelFor(model => model.Score, "New Score   ");
                                    @Html.TextBoxFor(model => model.Score, new { maxlength = 10, style = "width:125px" })
                                    <input type="submit" name="submitButton" value="Update" />
                               }
                           }
                       }
                   }
                </fieldset>
            }
       }






[HttpPost]
        public ActionResult EventResults(Results res)
        {
           //stuff
        }

My problem is I want to pass in the value of the current result-set, not the Result model object.
For example, when I put the value '15' into the text box and click 'Update', I'm passing the Result model object to the httppost method, which has everything set to null other than the 'score' field that I just entered.

Am I over complicating this? Is there an easier way?

I tried using the following, but it didn't seem to work either:

 @Html.LabelFor(model => model.Score, "New Score   ");
                                @Html.TextBoxFor(model => model.Score, new { maxlength = 10, style = "width:125px" })
                                @Html.HiddenFor(model => model.EventID);
                                @Html.HiddenFor(model => model.CompetitorEmail);
                                <input type="submit" name="submitButton" value="Update" />
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.