p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Binding SQLDataSource To A Label Control (http://p2p.wrox.com/showthread.php?t=52800)

sg225551 January 17th, 2007 02:41 AM

Binding SQLDataSource To A Label Control
 
hi

I have a sqlDatasource using "Select Count(*) as myCount from tableA"

Now, how do i bind the myCount field to a label control text property?

I don't seems to find any databinding properties for a label control.

thanks


wehttam42 January 16th, 2008 10:36 AM

Try this:
I have a sqlDataSource which returns a single row and a single column (its looking up a user's name based on the authenticated name on for the page)

First, assign the results of the sqlDataSource to a dataview.
Then assign the first item (row) of the dataview to a datarowview.
Then assign the column (UserName in my case) to the text of your label.

Dim dv As DataView = CType(SqlDataSource1.Select(DataSourceSelectArgume nts.Empty), DataView)

Dim dr As DataRowView = dv.Item(0)

lblUserName.Text = dr.Item("UserName")


All times are GMT -4. The time now is 02:08 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.