Hi experts,
I am having trouble calling the cached dataview session and
dataview.rowfil ter session in the pageIndexChange d event.
Currently, if user goes to page 2, the datagrid displays data without
the rowfilter that user selected from 5 dropdownlists.
I received the exception error on the code I wrote for calling the
cached session in PageIndexChange d:
Exception Details: System.NullRefe renceException: Object reference not
set to an instance of an object.
on dv.RowFilter = Session("Cached Filter")
Can someone show me how to correct the problem?
Thank you.
--------------------------------------------------------------
Sub BindTheData()
Dim strSql As New SqlCommand
Dim dtrDataGrid As SqlDataReader
Dim dataAdapter As New SqlDataAdapter
Dim dataSet As New DataSet
Dim Source As DataView
Source = CType(Session(" CachedGrid"), DataView)
conHDDb.Open()
strSql.CommandT ext = "SELECT J.Job_ID, J.J_Open_Date,
J.J_Due_Date, J.J_Location FROM Job_Tracking_Ta ble J order by Job_ID
desc"
strSql.Connecti on = conHDDb
strSql.CommandT ype = CommandType.Tex t
dataAdapter.Sel ectCommand = strSql
dataAdapter.Fil l(dataSet, "Job_Tracking_T able")
Dim JobInfo As DataTable =
dataSet.Tables( "Job_Tracking_T able")
Dim dvJobInfo As New
DataView(dataSe t.Tables("Job_T racking_Table") )
Session("Cached Grid") = Source
dvJobInfo.Sort = strViewString
dvJobInfo.RowFi lter = strDMFiltering &
strLocFiltering & strDueDateFilte ring &
strPostedDateFi ltering & strCatgFilterin g
Session("Cached Filter") = dvJobInfo.RowFi lter
DataGrid1.DataS ource = dvJobInfo
Session("JobSes sion") = dvJobInfo
DataGrid1.DataB ind()
conHDDb.Close()
End If
End Sub
Sub DataGrid1_PageI ndexChanged(ByV al sender As System.Object, ByVal e
As DataGridPageCha ngedEventArgs) Handles DataGrid1.PageI ndexChanged
Dim dv As New DataView
dv = Session("Cached Grid")
dv.RowFilter = Session("Cached Filter")
DataGrid1.Curre ntPageIndex = e.NewPageIndex
BindTheData()
End Sub
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*