You can declare a page level variable to store the results for your query and then reuse it.
Protected dsResults As DataSet
Protected Function LoadComments()
Dim dsComments As DataSet
'Add other validation here, eg - check for tables and rows, etc.
If Not IsNothing(dsResults) Then
dsComments = dsResults
Else
'go to db and perform your sql command
End If
Return dsComments
End Function
If you need to persist this dataset across postbacks, you can look at moving it to viewstate or session as well.
"What I hear, I forget; What I see, I remember; What I do, I understand." --Confucius
Remeber to Mark as Answer if this post helped you.
grundebar
Contributor
4515 Points
726 Posts
Re: Populating a DropDownList For Use Multiple Times in a DataGrid
Apr 30, 2012 07:59 PM|LINK
You can declare a page level variable to store the results for your query and then reuse it.
Protected dsResults As DataSet Protected Function LoadComments() Dim dsComments As DataSet 'Add other validation here, eg - check for tables and rows, etc. If Not IsNothing(dsResults) Then dsComments = dsResults Else 'go to db and perform your sql command End If Return dsComments End FunctionIf you need to persist this dataset across postbacks, you can look at moving it to viewstate or session as well.
Remeber to Mark as Answer if this post helped you.