I am new to .net completely and I just need to know the syntax, or possible functions to put in my if statement to check if <% If Model.contacts Is Null Then%>
which isn't correct.
Where Model.contacts
comes from my ClientViewModel, and Model.contacts
is of type System.Linq.IQueryable(Of Contact)
Here is the code for addresses...
<% If Model.addresses Is Nothing Then %>
<table class="edit">
<tr>
<td>
There are no Addresses associated with this Client, click the 'Create' Button to add contacts.
</td>
</tr>
</table>
<% Else%>
<table class="child">
<tr>
<th>
Actions
</th>
<th>
Street
</th>
<th>
City
</th>
<th>
State
</th>
<th>
Country
</th>
<th>
Zip
</th>
</tr>
<% For Each item In Model.addresses%>
... shows more table rows...
<% Next%>
</table>
<% End If%>
And it renders just the headers w/ more table rows from the For Each statement
And here is how we get Model.addresses from the ClientViewModel
Public Class ClientViewModel
Private _this_client As Client
Private _these_contacts As System.Linq.IQueryable(Of Contact)
Private _these_addresses As System.Linq.IQueryable(Of Address)
Private _these_statuses
Sub New(ByVal this_client As Client, ByVal these_contacts As System.Linq.IQueryable(Of Contact), ByVal these_addresses As System.Linq.IQueryable(Of Address), ByVal these_statuses As System.Collections.IEnumerable)
_this_client = this_client
_these_contacts = these_contacts
_these_addresses = these_addresses
_these_statuses = these_statuses
End Sub
Public ReadOnly Property contacts As System.Linq.IQueryable(Of Contact)
Get
Return _these_contacts
End Get
End Property
Public ReadOnly Property addresses As System.Linq.IQueryable(Of Address)
Get
Return _these_addresses
End Get
End Property
The template is
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of TotallyAwesomeCRM.ClientViewModel)" %>
List item