Can Dataset work in disconnected?

A

Anandvj

Hello

Here is my requirement

Dim oCategories as Dataset
Dim ds as Dataset
Private Sub Page_Load(...)
If Not Page.IsPostBack Then
oCategories = new Dataset
ds = new dataset
Dim busObj as XXX


' Get values as dataset from business object
oCategories = busObj.GetCategories()

' Assign it to another Dataset
ds = oCategories
BindData()
End If
End Sub

Private Sub BindData()
If ds.Tables(0).Rows.Count() > 0 Then
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Else
'Handle Error
End If
End Sub

Paging is enabled in the datagrid. So...

Sub NewPage(...)
DataGrid1.CurrentPageIndex = e.NewPageIndex
Call Binddata()
End Sub

When i try to call the Subroutine BindData(), it gives error "Object
reference not set to an instance of an object" which is because "ds"
is out of scope.

Can Dataset work in disconnected? Is there a way to store the dataset
so that i don't have to access the business object every time i
navigate across pages.

Thanks
Anand
 
M

Miha Markic

Hi,

It is probably that busObj.GetCategories() returns null value (or there are
no tables within it) which you assign to ds later.
 

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

Top