How do you Populate labels from a sqlDataReader in a separate clas

B

bthumber

My web has a record cover. When users enters the ID, the record cover opens.
The cover gets its data from a database. If I did all of the work in my web
site I could use:

Label1.text = getOrdinal("...");

But I want a class method that is generic. How would I do that? Could I
assign the ordinal to a session? Then assign the session to Label1?

Session["toMyLabel"] = getOrdinal("..."); ??? Before anyone ask "why would I
do that, I'm trying to figureout how to get the data from my class to my web
site.
 
S

Scott M.

bthumber said:
My web has a record cover. When users enters the ID, the record cover
opens.
The cover gets its data from a database. If I did all of the work in my
web
site I could use:

Label1.text = getOrdinal("...");

But I want a class method that is generic. How would I do that? Could I
assign the ordinal to a session? Then assign the session to Label1?

Session["toMyLabel"] = getOrdinal("..."); ??? Before anyone ask "why would
I
do that, I'm trying to figureout how to get the data from my class to my
web
site.

Binding the data to a Session doesn't solve anything. Your class shouldn't
have to know anything about the UI that will show the data returned from the
class. Your class should just have a method that returns data of a
particular type. If you want to use your class from a web page, you could
just make an instance of the class within the web page's code and set the
label's text to the data returned from the class method.

[Web Page Code]
Sub Button1_Click(Sender as Objecct, e as EventArgs)

Dim obj As New RecordCover
lblData.Text = obj.GetInformation.ToString

End Sub

-Scott
 
B

bthumber

But I want to put row0, column0 in label1, row1, column1 in label2 and so on,
how is that done?

Scott M. said:
bthumber said:
My web has a record cover. When users enters the ID, the record cover
opens.
The cover gets its data from a database. If I did all of the work in my
web
site I could use:

Label1.text = getOrdinal("...");

But I want a class method that is generic. How would I do that? Could I
assign the ordinal to a session? Then assign the session to Label1?

Session["toMyLabel"] = getOrdinal("..."); ??? Before anyone ask "why would
I
do that, I'm trying to figureout how to get the data from my class to my
web
site.

Binding the data to a Session doesn't solve anything. Your class shouldn't
have to know anything about the UI that will show the data returned from the
class. Your class should just have a method that returns data of a
particular type. If you want to use your class from a web page, you could
just make an instance of the class within the web page's code and set the
label's text to the data returned from the class method.

[Web Page Code]
Sub Button1_Click(Sender as Objecct, e as EventArgs)

Dim obj As New RecordCover
lblData.Text = obj.GetInformation.ToString

End Sub

-Scott


.
 
S

Scott M.

Have your class expose a method that returns all the data the application is
going to need in a DataSet, then your main applicaiton can grab whatever
data it needs and put it wherever it needs it.

-Scott

bthumber said:
But I want to put row0, column0 in label1, row1, column1 in label2 and so
on,
how is that done?

Scott M. said:
bthumber said:
My web has a record cover. When users enters the ID, the record cover
opens.
The cover gets its data from a database. If I did all of the work in my
web
site I could use:

Label1.text = getOrdinal("...");

But I want a class method that is generic. How would I do that? Could I
assign the ordinal to a session? Then assign the session to Label1?

Session["toMyLabel"] = getOrdinal("..."); ??? Before anyone ask "why
would
I
do that, I'm trying to figureout how to get the data from my class to
my
web
site.

Binding the data to a Session doesn't solve anything. Your class
shouldn't
have to know anything about the UI that will show the data returned from
the
class. Your class should just have a method that returns data of a
particular type. If you want to use your class from a web page, you
could
just make an instance of the class within the web page's code and set the
label's text to the data returned from the class method.

[Web Page Code]
Sub Button1_Click(Sender as Objecct, e as EventArgs)

Dim obj As New RecordCover
lblData.Text = obj.GetInformation.ToString

End Sub

-Scott


.
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top