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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:00:06+00:00 2026-06-15T10:00:06+00:00

I have the following view: @using SuburbanCustPortal.SuburbanService <br /> <br /> <table> @if (ViewData[CustomerData]

  • 0

I have the following view:

@using SuburbanCustPortal.SuburbanService

<br />
<br />
<table>

      @if (ViewData["CustomerData"] != null)
       {
         foreach (var usr in (IEnumerable<CustomerData>) ViewData["CustomerData"])
         {

           using (Html.BeginForm("ShowCustomer2", "Customer", FormMethod.Post))
           {
             <tr>              
               @Html.HiddenFor(model => @usr.AccountId)

               <td>
                 <input id="btn" type="submit" value="View"/>               
               </td>

               <td>
                 @usr.Branch-@usr.AccountNumber
               </td>

               <td>
                 @usr.Name
               </td>

               <td>
                 @usr.DeliveryStreet
               </td>

             </tr>            

           }
         }
       }

</table>
<br />

I’d like to get the AccountId of the button clicked. It lists all of the accounts that are on that login.

I’m getting null no matter how I reference it:

[HttpPost]
public ActionResult ShowCustomer2(FormCollection formCollection)
{

  var corpid = MiscClasses.GetCookieInfo.TokenId;
  var acctid = formCollection.Get("AccountId");
  MiscClasses.GetCookieInfo.CurrentAccountGuid = acctid;

  var sb = new StringBuilder();
  sb.AppendLine("SuburbanCustPortal,Controllers.CustomerController.ExistingAccounts");
  sb.AppendLine(string.Format("corpid: {0}", corpid));
  sb.AppendLine(string.Format("acctid: {0}", acctid));
  Logging.LogInfo(sb.ToString(), _asName);

  var cr = new CustomerRequest();
  cr.CompanyId = corpid;
  cr.Account = acctid;

  return View("AccountScreen", _client.GetCustomerByGuid(cr));
}

Anyone tell me what I’m doing wrong?

UPDATE

I made the following change in the view:

@Html.Hidden(@usr.AccountId)

and as:

@Html.Hidden(usr.AccountId)

I added the lines just to verify the controller code:

var acctid = formCollection["AccountId"];
acctid = formCollection.Get("AccountId");

Both are still coming out as null.

  • 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-06-15T10:00:09+00:00Added an answer on June 15, 2026 at 10:00 am

    you are using property of a class called CustomerData.it will produce CustomerData.AccountId for your hidden field name attribute.try rendering hidden tag manually like this:

    <input type="hidden" name="AccountId" value="@usr.AccountId">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following in my view: <%using (Html.BeginForm()) {%> <% foreach (var item
I have following view <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <h2>Tables <%=ViewData[RetriverName] %></h2> <%using (Html.BeginForm(ResfreshSelectedTables, Home))
In my view I have the following code: @using (Html.BeginForm()) { @Html.TextBox(Date2, Model.Date2) <br/>
In an MVC3 app, i have the following View: @using (Html.BeginForm(Index, Search, new {query
I have the following View code: @using (Html.BeginForm(Login, Press, FormMethod.Post)) { <fieldset> <legend>User Registration</legend>
I have the following code on a view: @using (Html.BeginForm()) { <div class=select-box form>
I have the following partial view code @model IEnumerable<PDoc.Web.Models.UserDocModel> @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using
I have the following in my Razor view: @using (Html.BeginForm(Edit, MyController, FormMethod.Post)) { <div
I have the following view: <h2> Contract</h2> @Using Html.BeginForm() @Html.ValidationSummary(False) @<fieldset> <legend>Hire Contract</legend> <div
I have the following view: <h2>enter the student name to search</h2> @using (Html.BeginForm()) {

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.