equal to the results of a sql query?
This seems like it should be simple, but I can't seem to get it done.Well what do you get as a return? a SqlDataReader, DataView?
to get every row into the table you'll have to loop around, otherwise, use a
DataGrid to display row by row:
while(pData.Read())
Label.Text += pData.GetString(0);
Hope you getting string!
Al
"Roy" wrote:
> Could someone please post some sample code on how to set an <asp:label>
> equal to the results of a sql query?
> This seems like it should be simple, but I can't seem to get it done.
>
y,
If you are going to have only one value in your result of a sqlquery thenyou
can use the following code to bind that single value to a label box.
Store that single value in a variable,say "MyVariable" for example, and
assign it to label cotrol as follows.
<asp:Label id="Label1" Text ='<%# MyVariable %>' runat=server/
You've to write the following line in one of your event's let us Page_Load
event
Page.DataBind();
cheers,
Jerome. M
"Roy" wrote:
> Could someone please post some sample code on how to set an <asp:label>
> equal to the results of a sql query?
> This seems like it should be simple, but I can't seem to get it done.
>
Thanks for the input guys.
Basically, I'm trying to set a label equal to a specific row in a
table. The row would have about 6 columns in it, but it would always be
just a single row. By the same token, I'd like it to look good... Can I
set it equal to a specific field? IOW, break up the row into it's
constituent parts?
0 comments:
Post a Comment