using DisplayFor in a table

I am trying to use DisplayFor in a table like so:
<table>
   <tr>
      <td>@html.LabelFor(model => model.name)</td>
      <td>@html.DisplayFor(model => model.name)</td>
      <td>@html.LabelFor(model => model.street)</td>
      <td>@html.DisplayFor(model => model.street)</td>
   </tr>
</table>

BUT, it displays the labels together and then the values!  I don't understand!
dan hendersonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
Rather than table use bootstrap grid that comes by default with an asp.net mvc project:

<div class="row">
	<div class="col-xs-3">
		@html.LabelFor(model => model.name)
	</div>
	<div class="col-xs-3">
		@html.DisplayFor(model => model.name)
	</div>
	<div class="col-xs-3">
		@html.LabelFor(model => model.street)
	</div>
	<div class="col-xs-3">
		@html.DisplayFor(model => model.street)
	</div>
</div>

Open in new window

P.S. I f more help needed please post VS/asp.net mvc version as well as a screenshot of what you have vs what you would like to see (Use excel to prototype)
0
dan hendersonAuthor Commented:
Your post is exactly what I started with ... in fact, that is how my Edit view is contructed.  But when I used the @Html.DisplayFor() it put the displayed values at the end of the line with all the LabelFor()'s at the start of the line:
label, label, displayfor, displayfor.  That is why I tried using a table, so the alignment would be correct (although it isn't).

I am using VS 2017 and MVC 5.
0
Miguel OzSoftware EngineerCommented:
Use text-* classes from bootstrap.
<div class="row">
	<div class="col-xs-3">
		@html.LabelFor(model => model.name)
	</div>
	<div class="col-xs-3 text-center">
		@html.DisplayFor(model => model.name)
	</div>
	<div class="col-xs-3">
		@html.LabelFor(model => model.street)
	</div>
	<div class="col-xs-3 text-center">
		@html.DisplayFor(model => model.street)
	</div>
</div>

Open in new window


All display code will display centred (assuming they are text of course)
P.S. I f more help needed please post  a screenshot of what you have vs what you would like to see (Use MS Excel to prototype - specify which alignment each cell must have)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.