databinding label control

D

DC Gringo

I'm trying to use a label control to show the # of records in my datagrid
and think I'm stuck on something simple...please help:

Error is: Name 'myDataSet1' is not declared.

FYI, it works fine if I use an integer value like "100" rather than
myDataSet1.Tables("CommunitiesT1")

-----MY LABEL CONTROL------

<asp:Label ID="lblRecordCount" runat="server" text="<%# RecordCount %>" />

------MY PROPERTY-----
ReadOnly Property RecordCount() as Integer
Get
Dim intRecordCount As Integer
intRecordCount = myDataSet1.Tables("CommunitiesT1")
Return intRecordCount
End Get
End Property

-----My SUB PAGE_LOAD------
Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

-----My DATA ACCESS CODE-----
Sub BindData()
Dim conString As String =
"server=server;database=db;uid=user;pwd=pwd;"
Dim myDataSet1 As New DataSet
Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
myDataAdapter1.Fill(myDataSet1, "CommunitiesT1")
DataGrid2.DataSource = myDataSet1.Tables("CommunitiesT1")

DataGrid2.DataBind()

lblRecordCount.DataBind()

End Sub
 
D

DC Gringo

If you scroll down it's in the section called "--My Data Access Code--

see below

-----_
DC G
 
F

Felbrigg

Dont know how I missed it!

Does this have to be a lable. As the control is a server control this may
be the issue. Have you tried using an HTML control to hold the value.
 

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,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top