Silly question on DataBinding

M

MikeD

Hello,

Sorry about this but I don't have my notes with me today. I wish to bind a
SQL SELECT statement to a set of .NET labels within a table. These are for
ReadOnly purposes and I don't think it necesitates a data container
(DataGrid, Repeater, etc) as it will only be one record at any time. I've
placed the labels in a table within a form, but can't remeber how to bind
them to columns from teh dataset.

Does anyone have a sample of how to go about this as I just can't remember?

Thanks,

<M>ike
 
S

Sam Fields

two ways:

1. Via back-end code only: Load your data in the page_load event and set
the .text property of the labels to the correct values.
2. Via front-end databinding AND back-end code: Create a protected
datatable at the class level. Fill it on page_load with the data. Call
MyLabel.DataBind() after filling the datatable. On your aspx page, set the
text property of the label as follows: Text='<%#
DataBinder.Eval(MyDataTable.Rows[0], "MyColumnName") %>'
 
M

MikeD

Thanks Sam,

I think that's what I was looking for.

<M>ike

Sam Fields said:
two ways:

1. Via back-end code only: Load your data in the page_load event and set
the .text property of the labels to the correct values.
2. Via front-end databinding AND back-end code: Create a protected
datatable at the class level. Fill it on page_load with the data. Call
MyLabel.DataBind() after filling the datatable. On your aspx page, set the
text property of the label as follows: Text='<%#
DataBinder.Eval(MyDataTable.Rows[0], "MyColumnName") %>'



MikeD said:
Hello,

Sorry about this but I don't have my notes with me today. I wish to bind a
SQL SELECT statement to a set of .NET labels within a table. These are for
ReadOnly purposes and I don't think it necesitates a data container
(DataGrid, Repeater, etc) as it will only be one record at any time. I've
placed the labels in a table within a form, but can't remeber how to bind
them to columns from teh dataset.

Does anyone have a sample of how to go about this as I just can't remember?

Thanks,

<M>ike
 

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
474,090
Messages
2,570,603
Members
47,223
Latest member
smithjens316

Latest Threads

Top