G
Guest
I have the following code in a on page load event of a user control:
<Other Code>
Dim dt As DataTable ' Also tried using New
dt = m_ClaimHistoryEntity.DataTable 'Error occurs here
m_ClaimHistoryEntity.Clear()
m_ClaimHistoryEntity.Load(FilterTable(dt))
dgClaimHistory.DataSource = m_ClaimHistoryEntity.DataTable
<Other Code>
Private Function FilterTable(ByVal currDataTable As DataTable) As
DataTable
Dim filterExpress As New StringBuilder
If m_bOpenOnly = True Then
'Limit to Open Status
filterExpress.Append("(Status = 'Open' OR IsNull(Status,'') =
'')")
End If
Dim myRow As DataRow
Dim dt As DataTable
Dim rowSet As DataRow()
rowSet = currDataTable.Select(filterExpress.ToString)
For Each myRow In rowSet
dt.Rows.Add(myRow)
Next myRow
Return dt
End Function
I keep receiving the generic error:
Object reference not set to an instance of an object
My goal is simple, I have a populated datatable called:
m_ClaimHistoryEntity.DataTable
I want to a subset of the data in the table, so I want to apply a filter.
Based on the results I want to set a datagrid datasource called:
dgClaimHistory
The code above started with the following simple syntax that keep growing as
tried to isolate the error:
Dim filterExpress As New StringBuilder
If m_bOpenOnly = True Then
'Limit to Open Status
filterExpress.Append("(Status = 'Open' OR IsNull(Status,'') =
'')")
End If
dgClaimHistory.DataSource =
m_ClaimHistoryEntity.DataTable.Select(filterExpress.ToString)
It there is a better approach I'm open to suggestions. If possible, please
provide VB examples. Thanks.
Josh.
<Other Code>
Dim dt As DataTable ' Also tried using New
dt = m_ClaimHistoryEntity.DataTable 'Error occurs here
m_ClaimHistoryEntity.Clear()
m_ClaimHistoryEntity.Load(FilterTable(dt))
dgClaimHistory.DataSource = m_ClaimHistoryEntity.DataTable
<Other Code>
Private Function FilterTable(ByVal currDataTable As DataTable) As
DataTable
Dim filterExpress As New StringBuilder
If m_bOpenOnly = True Then
'Limit to Open Status
filterExpress.Append("(Status = 'Open' OR IsNull(Status,'') =
'')")
End If
Dim myRow As DataRow
Dim dt As DataTable
Dim rowSet As DataRow()
rowSet = currDataTable.Select(filterExpress.ToString)
For Each myRow In rowSet
dt.Rows.Add(myRow)
Next myRow
Return dt
End Function
I keep receiving the generic error:
Object reference not set to an instance of an object
My goal is simple, I have a populated datatable called:
m_ClaimHistoryEntity.DataTable
I want to a subset of the data in the table, so I want to apply a filter.
Based on the results I want to set a datagrid datasource called:
dgClaimHistory
The code above started with the following simple syntax that keep growing as
tried to isolate the error:
Dim filterExpress As New StringBuilder
If m_bOpenOnly = True Then
'Limit to Open Status
filterExpress.Append("(Status = 'Open' OR IsNull(Status,'') =
'')")
End If
dgClaimHistory.DataSource =
m_ClaimHistoryEntity.DataTable.Select(filterExpress.ToString)
It there is a better approach I'm open to suggestions. If possible, please
provide VB examples. Thanks.
Josh.