473,404 Members | 2,187 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,404 software developers and data experts.

binding class variable to aspx page

I'm having trouble binding/displaying a class variable to
the display aspx page. Perhaps someone can suggest what I
am doing wrong.

###################################
Within the .aspx page I have this:
###################################
<td><%# p.ParcelName %></td>

#############################################
Within the code-behind page I have this:
#############################################
private void Page_Load(object sender, System.EventArgs e)
{
ParcelBusiness p = new ParcelBusiness(Convert.ToInt32
(Request.QueryString["parcelID"]));
DataBind();
}

p.ParcelName returns the parcel name from the business
layer in string format. When I attempt to access
the .aspx page, the following error is generated:

CS0246: The type or namespace name 'p' could not be found

Your advice will be greatly appreciated.

-Andrew
Nov 15 '05 #1
1 1941
You issue is one of scope. The object "p" is only in scope for that method.
In order to databind within the aspx page, which is a derived class from
your code-behind class, try moving the ParcelBusiness object to the class
level, and making it protected (so the derived class can see it).

[Add in Code-Behind]
protected ParcelBusiness p;

[Change In Page_Load]
p = new Parcel...etc...

--
James J. Foster, DotNetCoders
http://www.dotnetcoders.com

"Andrew Pasetti" <an***********@yahoo.com> wrote in message
news:0b****************************@phx.gbl...
I'm having trouble binding/displaying a class variable to
the display aspx page. Perhaps someone can suggest what I
am doing wrong.

###################################
Within the .aspx page I have this:
###################################
<td><%# p.ParcelName %></td>

#############################################
Within the code-behind page I have this:
#############################################
private void Page_Load(object sender, System.EventArgs e)
{
ParcelBusiness p = new ParcelBusiness(Convert.ToInt32
(Request.QueryString["parcelID"]));
DataBind();
}

p.ParcelName returns the parcel name from the business
layer in string format. When I attempt to access
the .aspx page, the following error is generated:

CS0246: The type or namespace name 'p' could not be found

Your advice will be greatly appreciated.

-Andrew

Nov 15 '05 #2

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

Similar topics

0
by: Gastin | last post by:
I am digesting a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
3
by: Simon Harris | last post by:
Hi All, I have a data grid which displays country names. I now wish to display the country flag images above the names. Can someone please advise how I display an image in a datagrid? I have a...
2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
5
by: Plat | last post by:
Summary: I've got some *.ASPX pages that still use COM objects. I'd like to enable Option Strict, but I get "error BC30574: Option Strict On disallows late binding" errors. How can I bypass this...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
15
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with...
9
by: Miro | last post by:
VB 2003 and Im still new to vb, so i hope i can explain this as best I can. I have a variable defined as such: ( simple example ) Dim AVariableOfSorts(,) As Object = _ { _ {"Last", "String",...
4
by: Mike | last post by:
I'm having trouble getting a gridview to bind. I probably missing something completely obvious and would appreciate any help on offer. I'm passing parameters via querystring, and have created a...
9
by: =?Utf-8?B?RGljaw==?= | last post by:
I have a function that creates a DataSet, populates its many DataTables and then returns the DataSet. I want to bind separate controls to each of the DataSet's DataTables, e.g. a separate...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.