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

Dont understand why this does not work

Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

........

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?

Nov 18 '05 #1
11 1568
You need a place to store the DataSet object. Try the following:

namepace humanres
{
public class main2 : System.Web.UI.Page
{
private DataSet _Employee = null;

public DataSet Employee
{
get
{return _Employee;}
set
{_Employee = value;}
}
}
}

That way the DataSet is getting stored somewhere in the object. Remember, a property is an accessor for a variable that enables setting the variable, and getting the variable. You need a seperate variable somewhere to actually store the object. In the sample code I just added an underscore to the name, but it could be anything as the name is not important, just that the get reuturns an actual variable and the set is able to set some variable.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage

"Mark Goldin" <ma********@comcast.net> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

.......

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?

Nov 18 '05 #2
Well, your example is a little too simple but...
Employee is a property of your main2 class located in the humanres namespace. Employee is an instance property, as opposed to a static propery. I wouldn't even think humanres.main2.Employee would compile.

From your user control, you could do

DataSet ds = ((humanres.main2)Page).Employee;

Page is the actual instance of your main2 class.

Do do it your way, you'd do

public static DatSet Employee{
get { return Employee; }
set { Employee = value; }
}

but I'm about 95% sure that isn't what you want and will not behave as you expect.

Also, I imagine it's just a typo, but your property "Employee"'s get accessor returns itself, which will have viscious side-effects....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mark Goldin" <ma********@comcast.net> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

.......

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?

Nov 18 '05 #3
How am I accessing Employee from the user control?

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
You need a place to store the DataSet object. Try the following:

namepace humanres
{
public class main2 : System.Web.UI.Page
{
private DataSet _Employee = null;

public DataSet Employee
{
get
{return _Employee;}
set
{_Employee = value;}
}
}
}

That way the DataSet is getting stored somewhere in the object.
Remember, a property is an accessor for a variable that enables setting the
variable, and getting the variable. You need a seperate variable somewhere
to actually store the object. In the sample code I just added an underscore
to the name, but it could be anything as the name is not important, just
that the get reuturns an actual variable and the set is able to set some
variable.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage

"Mark Goldin" <ma********@comcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

.......

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?
Nov 18 '05 #4
In your usercontrol use this line:

DataSet ds = ((humanres.main2)Page).Employee;

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eH*************@TK2MSFTNGP11.phx.gbl...
How am I accessing Employee from the user control?

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
You need a place to store the DataSet object. Try the following:

namepace humanres
{
public class main2 : System.Web.UI.Page
{
private DataSet _Employee = null;

public DataSet Employee
{
get
{return _Employee;}
set
{_Employee = value;}
}
}
}

That way the DataSet is getting stored somewhere in the object.
Remember, a property is an accessor for a variable that enables setting
the
variable, and getting the variable. You need a seperate variable somewhere
to actually store the object. In the sample code I just added an
underscore
to the name, but it could be anything as the name is not important, just
that the get reuturns an actual variable and the set is able to set some
variable.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage

"Mark Goldin" <ma********@comcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

.......

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?

Nov 18 '05 #5
I tried that.
Here is an error:

Server Error in '/humanres' Application.

----------------------------------------------------------------------------
----

Value cannot be null. Parameter name: dataSet
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: dataSet

Source Error:
Line 56: SqlConnection conn = new SqlConnection("Initial
Catalog=manpower;Data Source=devsrv00;uid=SoSTransWebUser;pwd=yurymark;" );
Line 57: SqlHelper.FillDataset(conn, CommandType.Text, "select * from
udf_getEmployeeDetails(" + EmployeeId + ")",
Line 58: ds, new string[]{"employee"});
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:#A*************@TK2MSFTNGP11.phx.gbl...
In your usercontrol use this line:

DataSet ds = ((humanres.main2)Page).Employee;

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eH*************@TK2MSFTNGP11.phx.gbl...
How am I accessing Employee from the user control?

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
You need a place to store the DataSet object. Try the following:

namepace humanres
{
public class main2 : System.Web.UI.Page
{
private DataSet _Employee = null;

public DataSet Employee
{
get
{return _Employee;}
set
{_Employee = value;}
}
}
}

That way the DataSet is getting stored somewhere in the object.
Remember, a property is an accessor for a variable that enables setting
the
variable, and getting the variable. You need a seperate variable somewhere to actually store the object. In the sample code I just added an
underscore
to the name, but it could be anything as the name is not important, just
that the get reuturns an actual variable and the set is able to set some
variable.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage

"Mark Goldin" <ma********@comcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Very simplified:

namespace humanres

{

public class main2 : System.Web.UI.Page

{

public DataSet Employee

{

get

{

return Employee;

}

set

{

Employee = value;

}

.......

Then to access Employee from the user control:

humanres.main2.Employee but it's (Employee) not there.

I am very confused.

Can some please, please explain what am I missing?


Nov 18 '05 #6
(Using Mark's example) Have you populated your private _Employee variable in
your main2 webform prior to trying to access it in the usercontrol using
main2's public Employee property?

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I tried that.
Here is an error:

Server Error in '/humanres' Application.

----------------------------------------------------------------------------
----

Value cannot be null. Parameter name: dataSet
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: dataSet

Source Error:
Line 56: SqlConnection conn = new SqlConnection("Initial
Catalog=manpower;Data Source=devsrv00;uid=SoSTransWebUser;pwd=yurymark;" );
Line 57: SqlHelper.FillDataset(conn, CommandType.Text, "select * from
udf_getEmployeeDetails(" + EmployeeId + ")",
Line 58: ds, new string[]{"employee"});
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:#A*************@TK2MSFTNGP11.phx.gbl...
In your usercontrol use this line:

DataSet ds = ((humanres.main2)Page).Employee;

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eH*************@TK2MSFTNGP11.phx.gbl...
> How am I accessing Employee from the user control?
>
> "Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
> news:eB**************@tk2msftngp13.phx.gbl...
> You need a place to store the DataSet object. Try the following:
>
> namepace humanres
> {
> public class main2 : System.Web.UI.Page
> {
> private DataSet _Employee = null;
>
> public DataSet Employee
> {
> get
> {return _Employee;}
> set
> {_Employee = value;}
> }
> }
> }
>
> That way the DataSet is getting stored somewhere in the object.
> Remember, a property is an accessor for a variable that enables setting
> the
> variable, and getting the variable. You need a seperate variable somewhere > to actually store the object. In the sample code I just added an
> underscore
> to the name, but it could be anything as the name is not important,
> just
> that the get reuturns an actual variable and the set is able to set
> some
> variable.
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP- FrontPage
>
> "Mark Goldin" <ma********@comcast.net> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> Very simplified:
>
> namespace humanres
>
> {
>
> public class main2 : System.Web.UI.Page
>
> {
>
> public DataSet Employee
>
> {
>
> get
>
> {
>
> return Employee;
>
> }
>
> set
>
> {
>
> Employee = value;
>
> }
>
> .......
>
>
>
> Then to access Employee from the user control:
>
> humanres.main2.Employee but it's (Employee) not there.
>
> I am very confused.
>
>
>
> Can some please, please explain what am I missing?
>
>



Nov 18 '05 #7
No, I did not populate it.
I am trying to fill Employee with data in a user control and it fails.

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ot*************@TK2MSFTNGP11.phx.gbl...
(Using Mark's example) Have you populated your private _Employee variable in your main2 webform prior to trying to access it in the usercontrol using
main2's public Employee property?

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I tried that.
Here is an error:

Server Error in '/humanres' Application.


--------------------------------------------------------------------------

--
----

Value cannot be null. Parameter name: dataSet
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: dataSet

Source Error:
Line 56: SqlConnection conn = new SqlConnection("Initial
Catalog=manpower;Data Source=devsrv00;uid=SoSTransWebUser;pwd=yurymark;" ); Line 57: SqlHelper.FillDataset(conn, CommandType.Text, "select * from
udf_getEmployeeDetails(" + EmployeeId + ")",
Line 58: ds, new string[]{"employee"});
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:#A*************@TK2MSFTNGP11.phx.gbl...
In your usercontrol use this line:

DataSet ds = ((humanres.main2)Page).Employee;

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eH*************@TK2MSFTNGP11.phx.gbl...
> How am I accessing Employee from the user control?
>
> "Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
> news:eB**************@tk2msftngp13.phx.gbl...
> You need a place to store the DataSet object. Try the following:
>
> namepace humanres
> {
> public class main2 : System.Web.UI.Page
> {
> private DataSet _Employee = null;
>
> public DataSet Employee
> {
> get
> {return _Employee;}
> set
> {_Employee = value;}
> }
> }
> }
>
> That way the DataSet is getting stored somewhere in the object. > Remember, a property is an accessor for a variable that enables setting > the
> variable, and getting the variable. You need a seperate variable

somewhere
> to actually store the object. In the sample code I just added an
> underscore
> to the name, but it could be anything as the name is not important,
> just
> that the get reuturns an actual variable and the set is able to set
> some
> variable.
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP- FrontPage
>
> "Mark Goldin" <ma********@comcast.net> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> Very simplified:
>
> namespace humanres
>
> {
>
> public class main2 : System.Web.UI.Page
>
> {
>
> public DataSet Employee
>
> {
>
> get
>
> {
>
> return Employee;
>
> }
>
> set
>
> {
>
> Employee = value;
>
> }
>
> .......
>
>
>
> Then to access Employee from the user control:
>
> humanres.main2.Employee but it's (Employee) not there.
>
> I am very confused.
>
>
>
> Can some please, please explain what am I missing?
>
>



Nov 18 '05 #8
Well all the code that has been provided assumed that main2 filled the
dataset and you were trying to read it in the usercontrol.

I am terribly confused.

Are you trying to read the usercontrol's dataset from the webform? The
reverse of what I (we) thought.

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:uP**************@TK2MSFTNGP15.phx.gbl...
No, I did not populate it.
I am trying to fill Employee with data in a user control and it fails.

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ot*************@TK2MSFTNGP11.phx.gbl...
(Using Mark's example) Have you populated your private _Employee variable

in
your main2 webform prior to trying to access it in the usercontrol using
main2's public Employee property?

Greg

Nov 18 '05 #9
What I am trying to do is this:
I want to have a dataset that will be accessable from any part of the
project.
Some user contols will read it to populate other controls with data.
Some controls will save dataset to the server.

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Well all the code that has been provided assumed that main2 filled the
dataset and you were trying to read it in the usercontrol.

I am terribly confused.

Are you trying to read the usercontrol's dataset from the webform? The
reverse of what I (we) thought.

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:uP**************@TK2MSFTNGP15.phx.gbl...
No, I did not populate it.
I am trying to fill Employee with data in a user control and it fails.

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ot*************@TK2MSFTNGP11.phx.gbl...
(Using Mark's example) Have you populated your private _Employee variable
in
your main2 webform prior to trying to access it in the usercontrol

using main2's public Employee property?

Greg


Nov 18 '05 #10
When you say project do your mean a single webform, or multiple webforms?
If multiple, then you need to store it in cache or session so that you read
it from other pages. OR fill you dataset on every page_load on every
webform that you need it.

If you want the dataset to be accessible from multiple forms and
usercontrols on those forms, then simply use cache. If the dataset is
specific to a single user, then use session.

If you are loading it on EVERY page_load, then it makes sense (to me at
least) to not use cache or sesssion, and use the technique Karl showed to
make the ds on the webform accessible to all it's child usercontrols.

Maybe post some code.

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:ua*************@tk2msftngp13.phx.gbl...
What I am trying to do is this:
I want to have a dataset that will be accessable from any part of the
project.
Some user contols will read it to populate other controls with data.
Some controls will save dataset to the server.

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:ez*************@tk2msftngp13.phx.gbl...
Well all the code that has been provided assumed that main2 filled the
dataset and you were trying to read it in the usercontrol.

I am terribly confused.

Are you trying to read the usercontrol's dataset from the webform? The
reverse of what I (we) thought.

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:uP**************@TK2MSFTNGP15.phx.gbl...
> No, I did not populate it.
> I am trying to fill Employee with data in a user control and it fails.
>
> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> news:Ot*************@TK2MSFTNGP11.phx.gbl...
>> (Using Mark's example) Have you populated your private _Employee variable > in
>> your main2 webform prior to trying to access it in the usercontrol using >> main2's public Employee property?
>>
>> Greg



Nov 18 '05 #11
These "components" sounds more like a Data Access Layer class than a
usercontrol.

Greg
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
My project has one webform and a number of user and custom controls.
I need to be able to access that dataset from any code that is a part of
the
project.
So main form will have a component to populate that dataset with data,
another control to read from it, and another component to save to the
database.
So my thinking was to create a global property (dataset) to access it from
anywhere.
Am I having it all wrong?
"Greg Burns" wrote:
When you say project do your mean a single webform, or multiple webforms?
If multiple, then you need to store it in cache or session so that you
read
it from other pages. OR fill you dataset on every page_load on every
webform that you need it.

If you want the dataset to be accessible from multiple forms and
usercontrols on those forms, then simply use cache. If the dataset is
specific to a single user, then use session.

If you are loading it on EVERY page_load, then it makes sense (to me at
least) to not use cache or sesssion, and use the technique Karl showed to
make the ds on the webform accessible to all it's child usercontrols.

Maybe post some code.

Greg

"Mark Goldin" <ma********@comcast.net> wrote in message
news:ua*************@tk2msftngp13.phx.gbl...
> What I am trying to do is this:
> I want to have a dataset that will be accessable from any part of the
> project.
> Some user contols will read it to populate other controls with data.
> Some controls will save dataset to the server.
>
> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> news:ez*************@tk2msftngp13.phx.gbl...
>> Well all the code that has been provided assumed that main2 filled the
>> dataset and you were trying to read it in the usercontrol.
>>
>> I am terribly confused.
>>
>> Are you trying to read the usercontrol's dataset from the webform? The
>> reverse of what I (we) thought.
>>
>> Greg
>>
>> "Mark Goldin" <ma********@comcast.net> wrote in message
>> news:uP**************@TK2MSFTNGP15.phx.gbl...
>> > No, I did not populate it.
>> > I am trying to fill Employee with data in a user control and it
>> > fails.
>> >
>> > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
>> > news:Ot*************@TK2MSFTNGP11.phx.gbl...
>> >> (Using Mark's example) Have you populated your private _Employee
> variable
>> > in
>> >> your main2 webform prior to trying to access it in the usercontrol
> using
>> >> main2's public Employee property?
>> >>
>> >> Greg
>>
>>
>
>


Nov 18 '05 #12

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

Similar topics

10
by: Simon Mansfield | last post by:
I have been given a list of exercises to do by my tutor, one of which is this: http://www.cems.uwe.ac.uk/~amclymer/Software%20Design%20and%20C++/Exercises/Exercise%208/Exercise.html Which i am...
9
by: TCMA | last post by:
I am looking for some tools to help me understand source code of a program written in C++ by someone else. Are there any non-commercial, open source C or C++ tools to reverse engineer C or C++...
0
by: Mate Visky | last post by:
hi, i have a little problame. i got this xml file: ---- <?xml version="1.0" encoding="UTF-8" ?> - <out> - <design> - <html> - <!]> </html>
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
1
by: Merrua | last post by:
I dont understand how to do this I created a dialog based project and that is fine for most of my programming project, but one dialog box is going to generate a graph, and as far as i know from...
5
by: raagz | last post by:
Hi, I am using the .NET validation controls for validating . The validation works fine with IE but none of them work with Netscape 6 browser. Do i have to configure something in vS.NET to...
23
by: novice | last post by:
I dint find a proper group to post this, so i'm asking this question. If you think this question is irrelevent then dont answer, but i expect good replies from experts. I wondor, how these guys...
7
by: Maarten | last post by:
Hi, I have a gridview (2.0), in the page load I remove a couple of columns from the gridview which I dont need. (All the columns are databound) This works fine. But after a postback all the...
19
by: so many sites so little time | last post by:
the table is head the colunm is called body <?php //show_site.php // This script retrieves blog entries from the database. // Address error handing. ini_set ('display_errors', 1);...
6
by: Bishop | last post by:
a += (UInt32)(url + (url << 8) + (url << 16) + (url << 24)); I'm trying to understand what the above line of code does. I understand that the url part of (url << 8) returns part of the string...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.