I am trying to set up a page where the user can change data, and then click
cancel and the data will not be saved. Currently, I am saving the data in a
Session variable that is an array of a class I created:
public class cut
{
public cut()
{
ParallelDim = 'G';
cutPoint = ++numCuts;
Knom = 0;
Kmin = 0;
Kmax = 0;
//numCuts++;
}
public cut(cut myCut) //copy constructor
//**note, does NOT increment numCuts
{
ParallelDim = myCut.ParallelD im;
cutPoint = myCut.cutPoint;
Knom = myCut.Knom;
Kmin = myCut.Kmin;
Kmax = myCut.Kmax;
}
public char ParallelDim;
public int cutPoint;
public decimal Knom;
public decimal Kmin;
public decimal Kmax;
public static int numCuts = 0;
}
I realized that when I set my temporary array to equal the session array, it
was passing the values by reference, so I created new objects using a copy
constructor:
for(int i = 0; i < 20; ++i) //uses copy constructor to initiate myCuts and
make copy so the
{ //changes are not made to Session[allcuts]
myCuts[i] = new cut(((cut[])Session["allCuts"])[i]);
//uses copy constructor to make
identical array
}
This works in that it does create a new array that is not just a reference to
the old one, but for some reason I cannot write the data back to the session
array. I am fairly sure it should just work like this:
Session["allCuts"] = myCuts;
but I have also tried using the copy constructor again (reverse of above) and
setting each individual value of the class separately. Nothing will write
the data back to the session array.
If ANYONE has any ideas, I would greatly appriciate it.
--
Message posted via http://www.dotnetmonster.com 4 2327
If you are going the session route, I find it easier to store ina data
format, like a DataSet. This is not applicable for all.
If you are using a single page for the info, consider ViewState instead. You
are still better to control your own destiny, of course.
I have never had problems with objects in Session, but I am not extensive in
my use of Session either, as I can normally find a better way for my
applications.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
*************** *************** *************** ***
Think outside the box!
*************** *************** *************** ***
"Vince13 via DotNetMonster.c om" <u35350@uwewrot e in message
news:75692e1587 5a8@uwe...
>I am trying to set up a page where the user can change data, and then click
cancel and the data will not be saved. Currently, I am saving the data in
a
Session variable that is an array of a class I created:
public class cut
{
public cut()
{
ParallelDim = 'G';
cutPoint = ++numCuts;
Knom = 0;
Kmin = 0;
Kmax = 0;
//numCuts++;
}
public cut(cut myCut) //copy constructor
//**note, does NOT increment numCuts
{
ParallelDim = myCut.ParallelD im;
cutPoint = myCut.cutPoint;
Knom = myCut.Knom;
Kmin = myCut.Kmin;
Kmax = myCut.Kmax;
}
public char ParallelDim;
public int cutPoint;
public decimal Knom;
public decimal Kmin;
public decimal Kmax;
public static int numCuts = 0;
}
I realized that when I set my temporary array to equal the session array,
it
was passing the values by reference, so I created new objects using a copy
constructor:
for(int i = 0; i < 20; ++i) //uses copy constructor to initiate myCuts and
make copy so the
{ //changes are not made to Session[allcuts]
myCuts[i] = new cut(((cut[])Session["allCuts"])[i]);
//uses copy constructor to make
identical array
}
This works in that it does create a new array that is not just a reference
to
the old one, but for some reason I cannot write the data back to the
session
array. I am fairly sure it should just work like this:
Session["allCuts"] = myCuts;
but I have also tried using the copy constructor again (reverse of above)
and
setting each individual value of the class separately. Nothing will write
the data back to the session array.
If ANYONE has any ideas, I would greatly appriciate it.
--
Message posted via http://www.dotnetmonster.com
Vince13,
drop a Gridview on an ASP.NET page and put the following code in. This
should help explain what's happening with Session:
protected void Page_Load(objec t sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add( "Test");
DataRow row = dt.NewRow();
row["Test"] = "First";
dt.Rows.Add(row );
Session["dt"]=dt;
dt.Rows[0]["Test"] = "Second";
GridView1.DataS ource = (DataTable) Session["dt"];
GridView1.DataB ind();
}
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com
"Vince13 via DotNetMonster.c om" wrote:
I am trying to set up a page where the user can change data, and then click
cancel and the data will not be saved. Currently, I am saving the data in a
Session variable that is an array of a class I created:
public class cut
{
public cut()
{
ParallelDim = 'G';
cutPoint = ++numCuts;
Knom = 0;
Kmin = 0;
Kmax = 0;
//numCuts++;
}
public cut(cut myCut) //copy constructor
//**note, does NOT increment numCuts
{
ParallelDim = myCut.ParallelD im;
cutPoint = myCut.cutPoint;
Knom = myCut.Knom;
Kmin = myCut.Kmin;
Kmax = myCut.Kmax;
}
public char ParallelDim;
public int cutPoint;
public decimal Knom;
public decimal Kmin;
public decimal Kmax;
public static int numCuts = 0;
}
I realized that when I set my temporary array to equal the session array, it
was passing the values by reference, so I created new objects using a copy
constructor:
for(int i = 0; i < 20; ++i) //uses copy constructor to initiate myCuts and
make copy so the
{ //changes are not made to Session[allcuts]
myCuts[i] = new cut(((cut[])Session["allCuts"])[i]);
//uses copy constructor to make
identical array
}
This works in that it does create a new array that is not just a reference to
the old one, but for some reason I cannot write the data back to the session
array. I am fairly sure it should just work like this:
Session["allCuts"] = myCuts;
but I have also tried using the copy constructor again (reverse of above) and
setting each individual value of the class separately. Nothing will write
the data back to the session array.
If ANYONE has any ideas, I would greatly appriciate it.
--
Message posted via http://www.dotnetmonster.com
You can check out this article:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!151.entry
There is a 1.1 version at my blog as well.
I find it easier to store 1 (wrapper type object) instead of a bunch of
disconnected items.
"Vince13 via DotNetMonster.c om" <u35350@uwewrot e in message
news:75692e1587 5a8@uwe...
>I am trying to set up a page where the user can change data, and then click
cancel and the data will not be saved. Currently, I am saving the data in
a
Session variable that is an array of a class I created:
public class cut
{
public cut()
{
ParallelDim = 'G';
cutPoint = ++numCuts;
Knom = 0;
Kmin = 0;
Kmax = 0;
//numCuts++;
}
public cut(cut myCut) //copy constructor
//**note, does NOT increment numCuts
{
ParallelDim = myCut.ParallelD im;
cutPoint = myCut.cutPoint;
Knom = myCut.Knom;
Kmin = myCut.Kmin;
Kmax = myCut.Kmax;
}
public char ParallelDim;
public int cutPoint;
public decimal Knom;
public decimal Kmin;
public decimal Kmax;
public static int numCuts = 0;
}
I realized that when I set my temporary array to equal the session array,
it
was passing the values by reference, so I created new objects using a copy
constructor:
for(int i = 0; i < 20; ++i) //uses copy constructor to initiate myCuts and
make copy so the
{ //changes are not made to Session[allcuts]
myCuts[i] = new cut(((cut[])Session["allCuts"])[i]);
//uses copy constructor to make
identical array
}
This works in that it does create a new array that is not just a reference
to
the old one, but for some reason I cannot write the data back to the
session
array. I am fairly sure it should just work like this:
Session["allCuts"] = myCuts;
but I have also tried using the copy constructor again (reverse of above)
and
setting each individual value of the class separately. Nothing will write
the data back to the session array.
If ANYONE has any ideas, I would greatly appriciate it.
--
Message posted via http://www.dotnetmonster.com
I see what you're pointing out here, that the assignment operator merely
creates another reference to the same memory, but that's why I'm using the
copy contructor in the first place. That's also the part that works. What
I'm wondering is if the same issue (reference/value) is somehow not allowing
me to wirte back to the session variable.
Peter Bromberg [C# MVP] wrote:
>Vince13,
drop a Gridview on an ASP.NET page and put the following code in. This should help explain what's happening with Session:
protected void Page_Load(objec t sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add( "Test");
DataRow row = dt.NewRow();
row["Test"] = "First";
dt.Rows.Add(row );
Session["dt"]=dt;
dt.Rows[0]["Test"] = "Second";
GridView1.DataS ource = (DataTable) Session["dt"];
GridView1.DataB ind();
}
-- Peter Recursion: see Recursion site: http://www.eggheadcafe.com unBlog: http://petesbloggerama.blogspot.com bogMetaFinde r: http://www.blogmetafinder.com
>I am trying to set up a page where the user can change data, and then click cancel and the data will not be saved. Currently, I am saving the data in a
[quoted text clipped - 54 lines]
>> If ANYONE has any ideas, I would greatly appriciate it.
--
Message posted via http://www.dotnetmonster.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul Yanzick |
last post by:
Hello,
I am trying to develop a book tracking application for my capstone in
school, and am running into a problem.
The application is an ASP.Net application written in C#. The first page you
go to is a login form, which will set several session variables with the
name used to log in, appropriate security level and some other misc
variables, and then will go to a main menu for each particular security
level using Server.Transfer. ...
|
by: Greg Linwood |
last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost
embarrassing asking this as I've been using ASP since it was first released
& it really shouldn't be this hard to use - perhaps I'm just not very smart
or perhaps MS is making this too hard for us sql bunnies to understand - I
dunno, but I'd really appreciate someone explaining what I'm doing wrong
here & perhaps suggest a better approach..
I'm familiar with use of...
|
by: Oleg Ogurok |
last post by:
Hi all,
Is there a way to read other people's session variables?
I understand it makes sense that session state is on per-user basis, but
still...
Is there a way to get a collection of all current HttpSessionState objects
on the server, or at least get a reference to a HttpSessionState objects by
session ID ?
Thanks.
|
by: Randy |
last post by:
Hello,
I'm having a strange problem. I've got a .NET web app which uses Session
variables. Sometime, not all the time, they get cross threaded...that
is...one user will have another user's Session variable(s) data assigned to
them. I can't figure out why. I've read that other people are having this
problem too but I haven't found a resolution yet. Can someone please tell me
how I might go about fixing this?
Thanks
|
by: Alex D. |
last post by:
is it possible? pros and cons?
| |
by: |
last post by:
Simple question, I think...
I'm storing an object in the Session object.
In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction)
If I change any properties, I have to store it back into the session object to "update" it, right? Or will the changes to my object automatically be saved back into the session object?
Thanks,
Jerry
|
by: Santosh |
last post by:
Dear All
i am writting a code sending mail with attachement.
i am writting code for sending mail in one page and code for attaching
a file in the next page.
aftet attaching a file i am taking name of that file from attaching
file page to email page through in session file .i am giving a
facility of attaching five files to user . and i am taking names of
both files in session variables but user attach less than five five
|
by: BillE |
last post by:
When a user opens a new IE browser window using File-New-Window the
integrity of an application which relies on session state is COMPLETELY
undermined. Anyone who overlooks the fact that File-New-Window creates an
instance of IE in the same process with the same SessionID as the parent
window is in big trouble. This fundamentally restricts the usefullness of
using session state management.
I probably missed it somewhere - can...
|
by: Diffident |
last post by:
Hi All,
I am trying to perform a non-CPU bound operation in an asynchronous fashion
using 'Thread' and a delegate. Basically, I am spawning a thread using
ThreadStart and Thread.
My non-CPU bound operation needs to have access to Session variables; Even
though I embedded the state information (which also includes the context
object) in an object and passed the object to the Thread , I am unable to
access the Session variables. The...
|
by: ChrisAtWokingham |
last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart editing processes place a very heavy load on the server as the effects of the edit ripple through the organisation structure, requiring potentially large numbers of rows in one of the tables to be updated. (I have done it this way to make the more...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |