473,387 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

databinding label control

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

--
_____
DC G
Nov 18 '05 #1
3 1329
Wheres your definition for MyDataSet1?
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

--
_____
DC G

Nov 18 '05 #2
If you scroll down it's in the section called "--My Data Access Code--

see below

-----_
DC G

"Felbrigg" <so*****@microsoft.com> wrote in message
news:eU*************@TK2MSFTNGP09.phx.gbl...
Wheres your definition for MyDataSet1?
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

--
_____
DC G


Nov 18 '05 #3
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.

"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
If you scroll down it's in the section called "--My Data Access Code--

see below

-----_
DC G

"Felbrigg" <so*****@microsoft.com> wrote in message
news:eU*************@TK2MSFTNGP09.phx.gbl...
Wheres your definition for MyDataSet1?
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

--
_____
DC G



Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
1
by: dieter | last post by:
Two-way databinding (as described in http://dotnetjunkies.com/QuickStartv20/aspnet/doc/data/templates.aspx) works fine for me if I use it within aspx-files. However, I would like to use it my...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
9
by: Nathan Sokalski | last post by:
I have a very simple UserControl which contains an Image and a Label, which I use to display an image with a caption. I am using this control inside a DataList, setting the two Public variables...
9
by: Nathan Sokalski | last post by:
I have a very simple UserControl which contains an Image and a Label, which I use to display an image with a caption. I am using this control inside a DataList, setting the two Public variables...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.