MVC View showing buttons with the same value
I have run into an issue with MVC 3.0 that must have something to do with my code, but I have been altering someone elses code that just left the company and seem to have screwed something up that I cannot figure out. I have a controller that looks like this:


 Direct Report Nominees

    /// <summary>
    /// Gets currently logged in user's direct reports nominees
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public ViewResult DirectReportNominees()
    {
        this.nominationRepository = new NominationRowsRepository("Data Source=" + MvcApplication.SERVER_NAME + "; Initial Catalog=Cinet;Integrated Security=True",
                                                    _currentuser.SAMAccountName);
        return View(nominationRepository.GetDirectReportNominees);
    }

    /// <summary>
    /// Overload that triggers when supervisor clicks
    /// Approve or Reject on Direct Report page
    /// </summary>
    /// <param name="submitButton"> button triggered to accept or Reject nomination</param>
    /// <param name="NominationID">ID of nomination to change status of</param>
    /// <returns></returns>
    [HttpPost]
    public ViewResult DirectReportNominees(string submitButton, string NominationID)
    {
        this.nominationRepository = new NominationRowsRepository("Data Source=" + MvcApplication.SERVER_NAME + "; Initial Catalog=Cinet;Integrated Security=True",
                                                    _currentuser.SAMAccountName);
        switch (submitButton)
        {
            case "Accept":

                NominationRow nomination = nominationRepository.GetNomination(NominationID);
                Employee nominatedUser = _adRepository.GetDirectoryUserInfo(nomination.NomineeLogin);

                // the email is sent from inside the repository
                nominationRepository.AcceptNomination(NominationID, nominatedUser);
                break;
            case "Reject":
                nominationRepository.RejectNomination(NominationID);
                break;
            default:
                break;
        }

        NominationID = "";
        return View(nominationRepository.GetDirectReportNominees);
    }


The Controllergathers from a Database class The various nominations that relate to a given logged in users report to and sends it to the below View


 The View looks like this:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<CINet.Areas.CAP.Models.CapDomain.Repositories.NominationStruct>>" %>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <%--<%: CINet.Views.Helpers.CssHelper.Css(Html, "~/Areas/CAP/Styles/Cap.css") %>--%>
    <link rel="Stylesheet" type="text/css" href="<%: Url.Content("~/Areas/CAP/Styles/Cap.css") %>" />
    </asp:Content>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    
    <div id="outsidewrapper">
    
    <div id="picture"></div>
    
    <div id="insidewrapper">
    <div id="navcontainer">
        <% Html.RenderAction("Navigation", "Cap"); %>
    </div>
    <div id="CapsDashboard">
        <h3>Direct Report Nominees</h3>
    
            <table>
            <colgroup>
                <col id="nominee" />
                <col id="nominatedBy" />
                <col id="reason" />
                <col id="status" />
            </colgroup>
            <thead>
                <th scope="col">Name</th>
                <th scope="col">Nominated By</th>
                <th scope="col">Reason</th>
                <th scope="col">Status</th>
                <th></th>
            </thead>
    
           <tbody>
        <% foreach (var nomination in Model) { %>
    
                    <tr>
                        <td><%: nomination.NomineeLogin %></td>
                        <td><%: nomination.NominatedBy %></td>
                        <td><%: nomination.NominationReason %></td>
                        <td><%: nomination.NominationStatus %></td>
                        <td>
                        <% if (nomination.NominationStatus == "Pending")
                           { %>
                           <%--Create Accept Button--%>
                           <% Html.BeginForm("DirectReportNominees", "Cap", FormMethod.Post); %>
    
                           <%: Html.Hidden("NominationID", nomination.NominationID.ToString()) %>
                           <input type="submit" name="submitButton" value="Accept" />
    
                           <% Html.EndForm(); %>
    
                           <%--Create Reject Button--%>
                           <% Html.BeginForm("DirectReportNominees", "Cap", FormMethod.Post); %>
    
                           <%: Html.Hidden("NominationID", nomination.NominationID.ToString()) %>
                           <input type="submit" name="submitButton" value="Reject" />
    
                           <% Html.EndForm(); %>
    
                        <% } %>
    
                        </td>
                    </tr>
                   
                <%--</div>--%>
        <% } %> 
        </tbody>
         </table>
         </div>
         </div>
         </div>
    </asp:Content>

obviously this is encapsulated inside a SiteMaster. The View takes in the model and spits out the various information regarding the user nominated along with a Reject and Approve Button. This buttons value should be set to the particular thing the user wishes to do and there is a hidden input field thats value is the Nomination GUID which is recieved via the database. The first round works great, but after that is completed, when the view returns from the HttpPost, all the hidden values now have the same value (GUID). The value happens to also always be the same as the GUID or row that was just approved/rejected. Any ideas on what could be holding this value? There is no ViewData that the programmer used that I can see and no errors in the View? I have tried stepping through the View's foreach loop when the post returns and they are all different, but by the time it gets to the browser, they are all the same value?? Very strange and hard to pin point.

Any suggestions??

The Class that the View is getting from is:

 

     public class NominationStruct
        {
            public string NominationID; // unique ID in DB
            public string NomineeLogin;
            public string NominationReason;
            public string NominationReasonWithBreaks;
            public string NominatedBy;
            public string NominationStatus;
    
        }

And the Model is:

     public class NominationsListViewModel
        {
            public IList<NominationRow> NominationRows { get; set; }
            public string CurrentTab { get; set; }
        }



MVC View showing buttons with the same value
===

I have run into an issue with MVC 3.0 that must have something to do with my code, but I have been altering someone elses code that just left the company and seem to have screwed something up that I cannot figure out. I have a controller that looks like this:


 Direct Report Nominees

    /// <summary>
    /// Gets currently logged in user's direct reports nominees
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public ViewResult DirectReportNominees()
    {
        this.nominationRepository = new NominationRowsRepository("Data Source=" + MvcApplication.SERVER_NAME + "; Initial Catalog=Cinet;Integrated Security=True",
                                                    _currentuser.SAMAccountName);
        return View(nominationRepository.GetDirectReportNominees);
    }

    /// <summary>
    /// Overload that triggers when supervisor clicks
    /// Approve or Reject on Direct Report page
    /// </summary>
    /// <param name="submitButton"> button triggered to accept or Reject nomination</param>
    /// <param name="NominationID">ID of nomination to change status of</param>
    /// <returns></returns>
    [HttpPost]
    public ViewResult DirectReportNominees(string submitButton, string NominationID)
    {
        this.nominationRepository = new NominationRowsRepository("Data Source=" + MvcApplication.SERVER_NAME + "; Initial Catalog=Cinet;Integrated Security=True",
                                                    _currentuser.SAMAccountName);
        switch (submitButton)
        {
            case "Accept":

                NominationRow nomination = nominationRepository.GetNomination(NominationID);
                Employee nominatedUser = _adRepository.GetDirectoryUserInfo(nomination.NomineeLogin);

                // the email is sent from inside the repository
                nominationRepository.AcceptNomination(NominationID, nominatedUser);
                break;
            case "Reject":
                nominationRepository.RejectNomination(NominationID);
                break;
            default:
                break;
        }

        NominationID = "";
        return View(nominationRepository.GetDirectReportNominees);
    }


The Controllergathers from a Database class The various nominations that relate to a given logged in users report to and sends it to the below View


 The View looks like this:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<CINet.Areas.CAP.Models.CapDomain.Repositories.NominationStruct>>" %>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <%--<%: CINet.Views.Helpers.CssHelper.Css(Html, "~/Areas/CAP/Styles/Cap.css") %>--%>
    <link rel="Stylesheet" type="text/css" href="<%: Url.Content("~/Areas/CAP/Styles/Cap.css") %>" />
    </asp:Content>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    
    <div id="outsidewrapper">
    
    <div id="picture"></div>
    
    <div id="insidewrapper">
    <div id="navcontainer">
        <% Html.RenderAction("Navigation", "Cap"); %>
    </div>
    <div id="CapsDashboard">
        <h3>Direct Report Nominees</h3>
    
            <table>
            <colgroup>
                <col id="nominee" />
                <col id="nominatedBy" />
                <col id="reason" />
                <col id="status" />
            </colgroup>
            <thead>
                <th scope="col">Name</th>
                <th scope="col">Nominated By</th>
                <th scope="col">Reason</th>
                <th scope="col">Status</th>
                <th></th>
            </thead>
    
           <tbody>
        <% foreach (var nomination in Model) { %>
    
                    <tr>
                        <td><%: nomination.NomineeLogin %></td>
                        <td><%: nomination.NominatedBy %></td>
                        <td><%: nomination.NominationReason %></td>
                        <td><%: nomination.NominationStatus %></td>
                        <td>
                        <% if (nomination.NominationStatus == "Pending")
                           { %>
                           <%--Create Accept Button--%>
                           <% Html.BeginForm("DirectReportNominees", "Cap", FormMethod.Post); %>
    
                           <%: Html.Hidden("NominationID", nomination.NominationID.ToString()) %>
                           <input type="submit" name="submitButton" value="Accept" />
    
                           <% Html.EndForm(); %>
    
                           <%--Create Reject Button--%>
                           <% Html.BeginForm("DirectReportNominees", "Cap", FormMethod.Post); %>
    
                           <%: Html.Hidden("NominationID", nomination.NominationID.ToString()) %>
                           <input type="submit" name="submitButton" value="Reject" />
    
                           <% Html.EndForm(); %>
    
                        <% } %>
    
                        </td>
                    </tr>
                   
                <%--</div>--%>
        <% } %> 
        </tbody>
         </table>
         </div>
         </div>
         </div>
    </asp:Content>

obviously this is encapsulated inside a SiteMaster. The View takes in the model and spits out the various information regarding the user nominated along with a Reject and Approve Button. This buttons value should be set to the particular thing the user wishes to do and there is a hidden input field thats value is the Nomination GUID which is recieved via the database. The first round works great, but after that is completed, when the view returns from the HttpPost, all the hidden values now have the same value (GUID). The value happens to also always be the same as the GUID or row that was just approved/rejected. Any ideas on what could be holding this value? There is no ViewData that the programmer used that I can see and no errors in the View? I have tried stepping through the View's foreach loop when the post returns and they are all different, but by the time it gets to the browser, they are all the same value?? Very strange and hard to pin point.

Any suggestions??

The Class that the View is getting from is:

 

     public class NominationStruct
        {
            public string NominationID; // unique ID in DB
            public string NomineeLogin;
            public string NominationReason;
            public string NominationReasonWithBreaks;
            public string NominatedBy;
            public string NominationStatus;
    
        }

And the Model is:

     public class NominationsListViewModel
        {
            public IList<NominationRow> NominationRows { get; set; }
            public string CurrentTab { get; set; }
        }


