Avatar of Moti Mashiah
Moti Mashiah
Flag for Canada

asked on 

Asp.net mvc5

Hi Guys,

I'm trying to break a string which comes from SQL to 4 columns and send it to view.
Here is how I'm getting the string from sql:

Open in new window

I divided it by 4 columns as you can see above,

Now I'm trying to loop it 4 time and send it to show in view:

My controller:
var x = aldb.ERPJournala(refid, trantype, batcnum).FirstOrDefault();

for (int i = 0; i < x.BillTo.Length; i++)
                if (i > 4)
                    jr.Billto = x.BillTo.Split('\n')[i];


Open in new window

So far everything works fine I query the billTo and split it to 4 columns.

Now I don't know what to do at my view side:
Here below you can see what I'm doing:

<div class="col-md-3 col-sm-3 col-xs-3">
                     @for (int i = 0; i < Model.Billto.Length; i++)
                         @Model.Billto<br />

Open in new window

The issue is that I'm getting just the last split like the last column.

I think my issue is the code in the view side.

Please,  help.

C#ASP.NET.NET Programming

Avatar of undefined
Last Comment
Moti Mashiah

8/22/2022 - Mon