Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populate Datalist on Web User Control

Posted on 2003-12-11
13
Medium Priority
?
347 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:CUTTHEMUSIC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922231
Forget about recordser, think ADO.NET with Datasets and DataTable
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922244
Dranizz I'm not sure what you mean. Maybe I am using the wrong terms.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922294
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
0
Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922348
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.AppSettings("readDbConnString")
        MyDataAdapter = New SqlDataAdapter("Stored_HomePage", ConString)
        MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
        'FILL DATALISTS
        MyDataAdapter.Fill(myDataSet)
        '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.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922404
by the way datalist is the control, Dataset is what you fill, it's a class
what is the problem exactly?
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922430
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/
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922500
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")
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922515
I can't use sessions.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922561
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.aspx",true);

And at page2 load you'll do this

System.Collections.Specialized.NameValueCollection 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"]
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922664
can you use server.transfer for a ASCX
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9922759
no...
You got yourself into something hard...
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 9922776
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.
0
 
LVL 8

Accepted Solution

by:
Dranizz earned 1000 total points
ID: 9922839
but if you use your ascx in a form and save the dataset in that form, then use the transfer, it could work

That's what I would do.

Use a property in the ascx to indicate the dataset to use or to save
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question