How to call a cached session in PageIndexChanged event?

J

JenHu

Hi experts,

I am having trouble calling the cached dataview session and
dataview.rowfilter session in the pageIndexChanged 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 PageIndexChanged:
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
on dv.RowFilter = Session("CachedFilter")

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.CommandText = "SELECT J.Job_ID, J.J_Open_Date,
J.J_Due_Date, J.J_Location FROM Job_Tracking_Table J order by Job_ID
desc"

strSql.Connection = conHDDb

strSql.CommandType = CommandType.Text

dataAdapter.SelectCommand = strSql

dataAdapter.Fill(dataSet, "Job_Tracking_Table")

Dim JobInfo As DataTable =
dataSet.Tables("Job_Tracking_Table")

Dim dvJobInfo As New
DataView(dataSet.Tables("Job_Tracking_Table"))

Session("CachedGrid") = Source

dvJobInfo.Sort = strViewString

dvJobInfo.RowFilter = strDMFiltering &
strLocFiltering & strDueDateFiltering &
strPostedDateFiltering & strCatgFiltering

Session("CachedFilter") = dvJobInfo.RowFilter

DataGrid1.DataSource = dvJobInfo

Session("JobSession") = dvJobInfo

DataGrid1.DataBind()

conHDDb.Close()

End If

End Sub





Sub DataGrid1_PageIndexChanged(ByVal sender As System.Object, ByVal e
As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged

Dim dv As New DataView

dv = Session("CachedGrid")

dv.RowFilter = Session("CachedFilter")

DataGrid1.CurrentPageIndex = e.NewPageIndex

BindTheData()

End Sub

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top