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

  • Thread starter Thread starter bthumber
  • Start date Start date
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.
 
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
 
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


.
 
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


.
 
Back
Top