CUTTHEMUSIC
asked on
Populate Datalist on Web User Control
I have a web form(page1.aspx) that requests 4 different recordsets from an sql 2000 server. In the page1 codebehind I bind the first 3 recordsets to 3 different datalists. I would like to bind the 4th recordset to a Datalist that is contained in a user control. I am an intermediate level programmer so details would be great. Thanks in advance
Forget about recordser, think ADO.NET with Datasets and DataTable
ASKER
Dranizz I'm not sure what you mean. Maybe I am using the wrong terms.
Well, in VB.NET we don't use recordset anymore, we use Datasets.
They are real representation of your data in the database, and it's disconnected.
http://visualbasic.about.com/library/weekly/aa041203a.htm
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatasetclasstopic.asp
They are real representation of your data in the database, and it's disconnected.
http://visualbasic.about.com/library/weekly/aa041203a.htm
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatasetclasstopic.asp
ASKER
Here is the code that I have
Private Sub getDataAndFill()
Dim myDataSet As New DataSet
Dim MyDataAdapter As SqlDataAdapter
Dim ConString As String = ""
'CONNECT TO DATABASE
ConString = ConfigurationSettings.AppS ettings("r eadDbConnS tring")
MyDataAdapter = New SqlDataAdapter("Stored_Hom ePage", ConString)
MyDataAdapter.SelectComman d.CommandT ype = CommandType.StoredProcedur e
'FILL DATALISTS
MyDataAdapter.Fill(myDataS et)
'BLOG ARCHIVE
DLBlogArchive.DataSource = myDataSet
DLBlogArchive.DataMember = "Table"
'BLOG
DLBlog.DataSource = myDataSet
DLBlog.DataMember = "Table1"
'PHOTOS
DLPopularPhotos.DataSource = myDataSet
DLPopularPhotos.DataMember = "Table2"
'LINKS
DLPopularLinks.DataSource = myDataSet
DLPopularLinks.DataMember = "Table3"
'BIND
DLBlogArchive.DataBind()
DLBlog.DataBind()
DLPopularPhotos.DataBind()
DLPopularLinks.DataBind()
End Sub
the DLBlogArchive is the datalist that I want to put on the web control since many pages will use it.
Private Sub getDataAndFill()
Dim myDataSet As New DataSet
Dim MyDataAdapter As SqlDataAdapter
Dim ConString As String = ""
'CONNECT TO DATABASE
ConString = ConfigurationSettings.AppS
MyDataAdapter = New SqlDataAdapter("Stored_Hom
MyDataAdapter.SelectComman
'FILL DATALISTS
MyDataAdapter.Fill(myDataS
'BLOG ARCHIVE
DLBlogArchive.DataSource = myDataSet
DLBlogArchive.DataMember = "Table"
'BLOG
DLBlog.DataSource = myDataSet
DLBlog.DataMember = "Table1"
'PHOTOS
DLPopularPhotos.DataSource
DLPopularPhotos.DataMember
'LINKS
DLPopularLinks.DataSource = myDataSet
DLPopularLinks.DataMember = "Table3"
'BIND
DLBlogArchive.DataBind()
DLBlog.DataBind()
DLPopularPhotos.DataBind()
DLPopularLinks.DataBind()
End Sub
the DLBlogArchive is the datalist that I want to put on the web control since many pages will use it.
by the way datalist is the control, Dataset is what you fill, it's a class
what is the problem exactly?
what is the problem exactly?
ASKER
I may be using the wrong terms.
I want to store the datalist in blogArchiveList.ascx and then fill the list from the page1.aspx code behind/
I want to store the datalist in blogArchiveList.ascx and then fill the list from the page1.aspx code behind/
use a session
save it on a session like this
On load
Session("Data")=myDataSet
and to get it back
dim data as Dataset
data=Session("Data")
save it on a session like this
On load
Session("Data")=myDataSet
and to get it back
dim data as Dataset
data=Session("Data")
ASKER
I can't use sessions.
hum...
then use the transfer method
Set to public attributes for your 2 strings in the Page1 class
like
Public Dataset Data;
server.Transfer("Page2.asp x",true);
And at page2 load you'll do this
System.Collections.Special ized.NameV alueCollec tion ColForm;
'Get the data from the source form
colForm=Request.Form
and gets the value from the source form
dim ds as Dataset
ds= colForm["Data"]
then use the transfer method
Set to public attributes for your 2 strings in the Page1 class
like
Public Dataset Data;
server.Transfer("Page2.asp
And at page2 load you'll do this
System.Collections.Special
'Get the data from the source form
colForm=Request.Form
and gets the value from the source form
dim ds as Dataset
ds= colForm["Data"]
ASKER
can you use server.transfer for a ASCX
no...
You got yourself into something hard...
You got yourself into something hard...
ASKER
maybe there is a better way then. The reason I am using a ascx page is because the blog archive is something that I want to use on almost every page. In old ASP I would use an include file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.