I'm showing a list of values in a view. It's working ok, but I need get only the first characters. I'm using Substring to implement it and it's working ok, in another case I use it for other value of my list but it's not working. I got this error
System.NullReferenceException: Object reference not set to an instance of an object.
Html code:
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.LeadName</td>
<td>@item.CarrierCode</td>
<td>@item.OrderRef.Substring(0, 5)...</td>
<td>@item.Carrier</td>
<td>@item.Ref</td>
<td>@item.TicketRef.Substring(0, 5)</td>
<td>@item.NoofNts</td>
<td>@item.DebtorCode</td>
<td>@item.InvDate.ToString("d")</td>
</tr>
}
</tbody>
"OrderRef" is working ok and the other one(TicketRef) doesn't work with the Substring but it's working without it.