Home Change receive values in front
Reply: 1

Change receive values in front

Pepe
1#
Pepe Published in 2018-02-08 16:30:29Z

I have foreach loop with razor engine like this

  @foreach (var item in Model.Item3.Matriz.Select((value, i) => new { i, value })) {
<tr>
  <td>@item.value.Unidad</td>
  <td class="hidden">@Html.Hidden("Item3.Matriz[" + item.i + "].Unidad", item.value.Unidad, new { @id = "Unidad_" + item.i })</td>

</tr>
}

So in table I can receive into Unidad value only values CORP, ALU AND PLA I want to know if it´s possible to replace that values with anothers. For example:

If I receive CORP from backend change it in front for CORPORATION

Is that possible?

Ryan Wilson
2#
Ryan Wilson Reply to 2018-02-08 16:35:38Z

Just use the string function Replace() to replace the value of Unidad like what I have done in the modification of your code sample below.

@foreach (var item in Model.Item3.Matriz.Select((value, i) => new { i, value })) {
    <tr>
      <td>@item.value.Unidad.ToString().Replace("CORP", "CORPORATION")</td>
      <td class="hidden">@Html.Hidden("Item3.Matriz[" + item.i + "].Unidad", item.value.Unidad, new { @id = "Unidad_" + item.i })</td>

    </tr>
    }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.394569 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO