Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrids' dataset using OO Model

Status
Not open for further replies.

sanctified

Programmer
Mar 9, 2006
65
GB
Hi Group,

An existing application exists which has been developed around the OO model. Lots of classes with standard routines etc.

I need to add an extra page which gets its data from the database and places this in a datagrid.

I've created an aspx page which holds the datagrid.

My code is as follows (snippet):


dsetIncomplete = New DataSet
eDMSDataHandler.PopulateIncompleteList(dsetIncomplete)
dagIncomplete.DataSource = dsetIncomplete
dagIncomplete.DataBind()



The method PopulateIncompleteList is in a class. Here it is in its entirety:

Public Shared Sub PopulateIncompleteList(ByVal dsetincomplete As DataSet)
Dim drIncomplete As SqlDataReader
Dim cmd As New SqlCommand
Dim cnn As New SqlConnection

cnn.ConnectionString = GetConnectionString() (method held in another class)
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "eDMS_ListAllIncompleteRecords"

cmd.Connection = cnn
cnn.Open()
drIncomplete = cmd.ExecuteReader


cnn.Close()
cnn.Dispose()
cmd.Dispose()
End Sub

However once this method is executed and my calling page is called, this line dagIncomplete.DataBind() gives an error:

The IListSource does not contain any data sources.

How can I get over this?

I've used similar syntax i.e. calling the class for drop down lists and this works, but I can't seem to get it to work for the grid.

Many thanks
 
Is the dataset dsetIncomplet declared within a local procedure, or is it a variable at page level? Either declare it at page level, or, change your sub to a function that returns a dataset.

Jim
 
Hi Jim,
It's declared at page level as a dataset.
The dropdown lists uses a sub and it returns an array;declared as an array at page level too. That worked, why not a dataset? Do I need to loop through it in my class?
 
You are creating a reader in your sub, but doing nothing with it. Use executedataset instead:
Code:
dsetincomplete = cmd.ExecuteDataSet
 
Hi Jim,
I'll give that a go. I'll let you know the outcome.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top