using session states

Hi,

Well I am slowly progressing with my project, thanks everyone for helping me, I can explain to you now my next step:

I have a form page with loads of fields(around 50) a mix of ddl's, text fields, checkboxes etc. that the user fills in e.g. to list ingredients and prices for a new article. From this I have created a dataset to hold all the info. Then I also have another page that is a datagrid that lists a summary of the users articles using the dataset but only a few of the fields, when the user wants to edit a row in the table they will get redirected back to the form and all the articles information will be filled into the appropriate fields. So my question:

Do I have to create session state variables for every single field and then set them in the form page's page_load handler? or is there a easier way, something like creating an object of the table row like:

datasetIndex = e.Item.ItemIndex
activeRow = oDsArticle.NewArticle(datasetIndex)

and sending it in a session state and then somehow I can access all the fields through this object?

0
sharon2ee
5/26/2005 11:23:46 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies
1042 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

Hi there,

I'd create a class with all the fields as properties and then store that in session.

ie

public class Article
Private m_Name as string
public property Name as string
Get
Return m_Name
Set(Value as string)
m_Name=Value

etc..etc...

dim MyArticle as new Article
MyArticle.Name="Fred"
session("CurrentArticle")=MyArticle

to get it back you could do
dim MyArticle as new Article=Ctype(session("CurrentArticle"),Article)

0
funkybeatz
5/26/2005 1:11:31 PM

I suggest using a NameValueCollection (in the System.Collection.Specialized namespace) and use the Control's ID as the key. You can then store this in a Session variable. When you use the Session variable you must cast it to a NameValueCollection before you can access the items in the Collection. For example:

To store the values:

   NameValueCollection controls = new NameValueCollection();
   controls[TextBox.ID] = TextBox.Text;
   controls[DropDownList.ID] = DropDownList.SelectedValue;
   Session["controls"] = controls;


To retrieve the values:

   NameValueCollection controls = Session["controls"] as NameValueCollection;
   TextBox.Text = controls[TextBox.ID];
   DropDownList.SelectedValue = controls[DropDownList.ID];


Steven Bey

Recursion: see Recursion
0
stevenbey
5/26/2005 2:03:18 PM


Hi Steve,

I took your advice and used the NameValue Collection. I declared the RowControl on my Datagrid page like this (I use vb.net):

Dim rowControls As New NameValueCollection
Dim Index As Integer

Index = e.Item.ItemIndex()
activeRow = oDsArticle.Article(Index)

rowControls.Add("ArticleDescription.ID", activeRow.ArticleDescription)


Then on my forms page I declared it as:

Private rowControls As NameValueCollection

Session.Add("oDsArticle", oDsArticle)
Session.Add("activeRow", activeRow)

Session.Add("rowcontrols", rowControls)

If activeRow.IsNewArticle = True Then
rowControls = New NameValueCollection

ArtDescription.Text = rowControls(articleDescription.ID)

But then I get an error here that "articleDescription"(just on the line above 'articledescription' is underlined not the '.ID')  is not declared. Can you see what I'm doing wrong?? I also tried it with ArtDescription.Text = rowControls.Item(articleDescription.ID) but it is the same result.
Sharon

0
sharon2ee
5/30/2005 12:51:18 PM
Where are you declaring articleDescription?
Steven Bey

Recursion: see Recursion
0
stevenbey
5/31/2005 10:49:05 AM

Hi Steve,

I declared an object of the row

Private
activeRow As WSData.DSArticle.ArticleRow

and thought that I can access all from that, do I have to declare all the fields from the row seperately on the form page?

Sharon

0
sharon2ee
5/31/2005 12:23:05 PM

It still isn't clear where activeDescription fits in to this scheme but if it's a Property/Field of the activeRow object, then you need to reference it as such, e.g. activeRow.activeDescription.ID.


Steven Bey

Recursion: see Recursion
0
stevenbey
5/31/2005 12:43:30 PM
Reply:

Similar Artilces:

Session State in Web Farms and Web Gardens Using InProc
Is it possible to do the session state control in any way using InProc State Management. I dont want to Keep a seperate Session State Process or SQL to be used for this.. Please suggest a solution.. Thanks firozOzman..::firozozman::.. If you have web garden, that means multiple processors in one machine and one ASP.NEt worker process per processor serving requests, that is multiple worker processes. Therefore each and every of these processes have separate copy of application state, in-process session state, ASP.NET cache, static data and so on. Basically same goes with web farm exc...

C#.NET WEB APPLICATION
hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

no session use in web form.??
Hi folks, I developed and application for "IT infrastucture support" and i used session level variables on client and admin. i have 50 % of my issues with session variables. is it possible to use constants or variables in any global file or module file.. any ideas what is the best practice for future and my current project.??   Thanks in advance..Jagjot SinghMCP, CCNA Can you post the problems you faced with session variables?   if you use sessions properly then it should not be a problem. go with some practical samples for using sessions. Then correc...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Using Session state in a web service
I have a web service and have created a basic Login method.  This method accepts a user name and password that is managed by a custom provisioning table in Oracle.  If the user name and password are correct, I want to set a Session variable that can be passed to the consuming client application.  I read an article about session state in web services and it appeared straight-forward, but I cannot seem to get it to work...so I guess I'm missing something.  Here's a sample of the web method code:1 [WebMethod(Description="Provides entry point to web service.&q...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Need Windows Form to Retrieve Information From Web Form
I have a cash and carry web site that customers can order products, the next day come in to the company to pay and pickup. I would like to create a windows application for the company to do two things: 1. download all the orders from the day before 2. upload price changes, product changes, category changes I've search the internet and forums and the only thing I can find that I think would actually link these two together would be a web service. Can you please tell me if I am heading in the right direction or if there is another method to link the two applications, if there are any pitf...

How use Session State in Atlas Web Services?
My usage is the same as the generic web services: [WebMethod(EnableSession=true)] public string HelloWorld() {       Session["test"] = test; } But get the NULLReference Exception. Does the Atlas not permited to use Session State? Or there is another way to use Session State in Atlas? Thanks Yes, there is a bug in the current drop that causes this.  We are VERY close to getting a new drop out that will address this. David...

Session state management using web services.
 Hi all ,i am working of a hospital management system which we desided to develop using atlas frame work. we have created the application main to sections using atlas script call back architecture. we are using scripts to pack the user entered data to the web service and in that web service we are entering the data in to the database.all this happening with out a post back of the page.now comes the problem. we are not being able to handle the user session properties. we came to know that we cant access session variables in web services. we are in a trap now. how we can manage the sessio...

Unable to use session state server....requires session state server version 2.0 or above.
So, I have Windows 2003 IIS latest service packs running. Its running .NET 2.0 and .NET 1.1 applications in seperate application pools. Just today I applied the following patch to the server. (The server is not running any 3.0 or 3.5 applications or application pools)  Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86 Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing upda...

using javascript to change .net web form properties
Hello everyone, I'm fairly new to ASP.NET and I'm trying to find the best solution to this problem I'm having.  I believe ultimately what I need to be able to do is change the ImageUrl value via javascript of an ImageButton.  A small example of what I'm working on can be found here in a javascript form:http://www.msu.edu/~sebenic3/This is a simple data input method for a survey. There are three distinct columns, when you select a number within a column it will change the .gif image to show it's selected and then populate the textbox with that value.  I...

Web Forms with no DLL using VS .NET IDE
Basically, I've been trying to make ASPX web pages with VS .NET and have learned a little of how to not use the DLL that gets created when the project is compiled and use the .VB source files themselves at run-time. I've been experimenting with changing the keyword CodeBehindFile to SRC; removing the project name from Inherits to look directly at the VB class (i.e. MyProject.MyClass to just MyClass.) I've been changing the private routines with in the class to be public. I have had sucess with getting the pages to work with code files. However, I've been having certain problems in .NET I...

Using excel/automation from a .net web form fails, why?
Hi all - From my codebehind I'm attempting to write the contents of a DataSet to Excel. However, it appears that I cannot start Excel from my codebehind to accomplish this. Doing so causes the following error: Cannot execute a program. The command being executed was "c:\winnt\microsoft.net\framework\v1.1.4322\csc.exe" /noconfig @"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\webservice_icspos_consumer\bd8c4cb9\af1c8054\s33rwgwf.cmdline". I've referenced Microsoft Excel 10.0 Object Library which also brings in - Microsoft Office 10.0 Obje...

Using Web.sitemap with cookieless sessions and forms authentication
Hi AllI'm creating a site using the Web.sitemap and SiteMapDataSource. All was well until I switched on cookieless security. The URLs displayed for links driven by the sitemap don't reflect the URIs for the logged on user (ie with the cookie values displayed as part of the URL). Is this a bug? If it is, is it a known bug? Regards Nigel Armstrong Nigel,  Can you explain your observations more?  I don't quite follow what you're describing.  I turned on cookieless security and my site navigation system seems to work fine in a Forms Auth site.  Thanks.--Dannydisclaimer: I...

SerializationException when using SQL Session State in a web farm
Hello gurus,I'm trying to web farm an ASP.NET 2.0 site, which works as expected in a single-server environment.  I've read lots of articles about session state in a load balanced web farm, but am still having problems.  Here are the steps I've taken:Configured load balancing for my two web servers, A and B, running Windows Server 2003, configured identically, with the latest patches installed.Ensured identical IIS configurations and files for the web site on each server.  The web site identifier shown in IIS on A and B is also identical.Tested browsing some simple ...

Web resources about - using session states - asp.net.web-forms

Barack Obama speech to joint session of Congress, February 2009 - Wikipedia, the free encyclopedia
Obama's first State of the Union Address was the 2010 State of the Union Address . The speech was delivered on the floor of the chamber of the ...

NRL: Canberra Raiders head to Stromlo for intense running session to counter rule change
The Canberra Raiders are adapting to the NRL's reduction in interchanges and ensuring their front-rowers are fitter to play extra minutes next ...

Perth pub, nightclub opening hours to extend - Sunday Sessions, WA
AS THE east coast of Australia cracks down on late-night drinking, Western Australia is heading in the opposite direction.

Perth Sunday session trading hours extended
Perth pubs and nightclubs can now keep their doors open longer on Sundays under new liquor laws that come into effect this weekend. Perth pubs ...

Aaron Paul Hosts Binge Watchers Anonymous Session for T-Mobile
Every weekday, we bring you the Ad Age/iSpot Hot Spots, new and trending TV commercials tracked by iSpot.tv, a company that catalogs, tags and ...

Should We Fear Peak Human?: Master Post for Uncharted 2015 Brad DeLong-Peter Leyden Session
**Jennie Eliot**: Your Uncharted Interview Video: To Brad, Peter.... >All links in one place: >* [Full video with highlights](http://reinven ...

Jeff Sessions: Supporting Citizenship for Illegals 'Should Be Disqualifying'
Jeff Sessions said supporting citizenship for illegals ought to be “disqualifying” for any candidate running to be the Republican nominee

TWIABP filmed a live session video for "I Can Be Afraid of Anything," add 2nd NYC show to tour
photo: TWIABP at LPR in August (more by Mimi Hong) The World Is A Beautiful Place & I Am No Longer Afraid To Die is on tour now supporting this ...

Saturday Sessions: Jeff Lynne of "Jeff Lynne's ELO" plays "Turn to stone" - Videos - CBS News
Jeff Lynne is one of the most influential rock musicians and producers ever, and is now leading a 21st-century version of a hit-making powerhouse. ...

Sen. Sessions: Take TPP Off The Fast Track And ‘Get Busy Defending The Interest Of The American People’ ...
Sen. Sessions: Take TPP Off The Fast Track And ‘Get Busy Defending The Interest Of The American People’

Resources last updated: 11/25/2015 2:16:05 PM