Moti Mashiah
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:
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:
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:
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.
Thanks.
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:
"ISLAND CONSTRUCTION \nISCON1 \nPO BOX 1210\n 35 BERNARD DR \n3239337"
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)
{
break;
}
else
{
jr.Billto = x.BillTo.Split('\n')[i];
}
}
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 />
}
</div>
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.
Thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Solved
Open in new window