Hello...i am trying to filter a datatable and rebind the results to my datagrid.
My datagrid columns display displayed like so:
<datagrid autogeneratecolumns=false>
<asp:templatecolumn>
<itemtemplate>
<%#Databinder.EvalContainer.Dataitem,"varLastName"
%>
</itemtemplate>
</asp:templatecolumn>
</datagrid>
When I run my initial query, I create a datatable, cache it and bind to the datagrid:
Dim Search As DataTable = New DataTable()
Dim dr As DataRow
Dim i As Integer
Dim adapter As SqlDataAdapter = New SqlDataAdapter()
adapter.SelectCommand = myCmd
adapter.Fill(Search)
Session("Results"
= Search
dgSearch.DataSource = Search
dgSearch.DataBind()
I want to take this datatable out of cache, filter it, insert the results into a new datatable and bind to the datagrid again.
I tried the following, but get an error 'System.Web.HttpException: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name varLastName.
Dim Filter, Sort As String
Dim tempdt As DataTable
Dim filterdt As DataTable
Dim drs() As DataRow
Dim dr As DataRow
Filter = " intEmployeeID > 0 "
Sort = " intEmployeeID DESC"
tempdt = CType(Session("Results"
, DataTable)
drs = tempdt.Select(Filter, Sort)
filterdt = New DataTable()
Dim row As DataRow
For Each row In drs
filterdt.ImportRow(row)
Next
Dim dv As DataView = filterdt.DefaultView
dgSearch.DataSource = dv
dgSearch.DataBind()
Thanks in advance!
My datagrid columns display displayed like so:
<datagrid autogeneratecolumns=false>
<asp:templatecolumn>
<itemtemplate>
<%#Databinder.EvalContainer.Dataitem,"varLastName"
</itemtemplate>
</asp:templatecolumn>
</datagrid>
When I run my initial query, I create a datatable, cache it and bind to the datagrid:
Dim Search As DataTable = New DataTable()
Dim dr As DataRow
Dim i As Integer
Dim adapter As SqlDataAdapter = New SqlDataAdapter()
adapter.SelectCommand = myCmd
adapter.Fill(Search)
Session("Results"
dgSearch.DataSource = Search
dgSearch.DataBind()
I want to take this datatable out of cache, filter it, insert the results into a new datatable and bind to the datagrid again.
I tried the following, but get an error 'System.Web.HttpException: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name varLastName.
Dim Filter, Sort As String
Dim tempdt As DataTable
Dim filterdt As DataTable
Dim drs() As DataRow
Dim dr As DataRow
Filter = " intEmployeeID > 0 "
Sort = " intEmployeeID DESC"
tempdt = CType(Session("Results"
drs = tempdt.Select(Filter, Sort)
filterdt = New DataTable()
Dim row As DataRow
For Each row In drs
filterdt.ImportRow(row)
Next
Dim dv As DataView = filterdt.DefaultView
dgSearch.DataSource = dv
dgSearch.DataBind()
Thanks in advance!