.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Storing session data continuouly

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net



Is it possible to store gridview session data after each postback. I have a gridview and a checkbox within. Each time a user clicks the checkbox, I like to store the gridview ID in a session. After browsing through various pages, I like this session data to continuously store the information up to 20mins?


How can I continously store the session variable. Please can someone provide a sample? Say a text box and if I enter 1 click on a hyperlink (where session variable is stored) return back to the page, enter 2 click hyperlink then I should get in the session 12?

Any one know how to do this? Please provide code in VB.

THanks! Nijojo

View Complete Post

More Related Resource Links

Storing large data in Session State

Hi, We have a scenario where we need to store large tables of data on Session in asp.net page. on a highlevel we have to store following data  1> A table (table 1) with 1000 rows and 8 to 10 columns. 2> A table(table 2) with 500 rows and 8 to 10 columns (actually user can add the data from table 1 to table 2, so as user keeps on adding from table 1 we remove the data and put it in table 2) 3> Another table(table 3) with 1000-1200 rows each having 3 columns. We are having a webfarm, so we need to store it in either SateServer of Oracle DB, please advise which one is better. What would be the performance implications of storing such huge data on the server. One more thing is at any point of time max of 70 -80 people will be accessing our website, so will this cause any performance degradation? Thanks in anticipation Harsha

Storing User Data



I'm trying to get the current logged in UserId Value, using this code

Protected Sub UserProfileDataSource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles UserProfileDataSource.Selecting      ' Get a reference to the currently logged on user      Dim currentUser As MembershipUser = Membership.GetUser()      ' Determine the currently logged on user's UserId value      Dim currentUserId As Guid = CType(currentUser.ProviderUserKey, Guid)      ' Assign the currently logged on user's UserId to the @UserId parameter      e.Command.Parameters("@UserId").Value = currentUserId End Sub

But, I getting an error (NullReferenceException), I did set a url authorization on the page that i try to get the logged in user information, witch is info.aspx, and I made the login.aspx control to be redirected to the info.aspx after the login process, But the info.aspx  only shows me (access in denied), how can i make this page knows that i am already logged in?

Web Q&A: Storing SQL Data, URL Query Length, and More


Find out the best way to store large amounts of XML data in SQL Server, along with the performance implications. What's the maximum length of an XML query to SQL Server in a URL?

Edited by Nancy Michell

MSDN Magazine May 2003

Using Session to pass data between forms


In my app, I am displaying an Rss Feed, I have a button that takes the user to another form where they can select a them.  Upon selecting the theme, they are taken back to the original form. 

If the user has selected which theme they want to view then they click on the button to change theme, I need to pass the information about what rss feed they were viewing through session so that once they select the theme they want they are redirected back to the main page and the rss feed they were viewing should still be displayed.

Since I've already bound the data to the xmlDataSource and DataList I am trying the following:

Session.Add("CurrentRssFeed", XmlDataSource1.DataFile);

Session.Add("CurrentDataList", DataList1);

I'm not sure I am passing the data over correctly and I'm not sure how to specify it in the page_preinit.

Any ideas???

send data in class object from one page to another using session


hello everybody

now i hav stored all data like user name, data fatched from database of that user

and i stored that data and user name such as:

string strUserName="user name"

dataset ds =new dataset();// data of that user

now i wan yo send d whole data from my login page to user profile page

can anybody help me for that...................

and plz tell me that how much is this way is benifitial to send data from one page to another page

plz........kindly waiting for positive rply

Changing aspx page causes session data to be lost...


Strange but true. Any ideas what might be causing this?


storing Session in sql server?



I want to show all the activities of the logged in user in a gridview. I am using VS 2010. please suggest some good ways of doing it.



Storing data into property

Hi, I have written a property globally on page load i am storing setting some value into that property but on button click i am not able to retrieve the data. Is there any alternate way to save the data other than viewstate or sessionstate. Ex: Partial Class _Default Inherits System.Web.UI.Page Private s As String Public Property Test() As String Get Return s End Get Set(ByVal value As String) s = value End Set End Property Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then s = "Test" End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click s = "Champ" End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox(s.ToString()) End Sub End Class

Storing multiple data types in a class?

I need help writing a class that will contain three values per item.  I'll be passing parameters to a report: Parameter Name, Data type (int, string, date, etc), and Value. When I pass those values to the report using the class they should be in original form (i.e. an integer should be a numeric, a string should be a string, etc.).  I can do it converting the data's value to strings on one end, and reconverting to the original data type on the other, which seems like a lot of runaround. Is there a simple way?  Also, if I'm able to store & retrieve the data in it's native format I don't need the "Data type" stored. Any help or tips will be appreciated.

Storing and retrieving historic data

Hi, I am looking at making my database historic and would like some pointers. Data older than 1 year does not need to be kept so every 12 months, data is "recycled". So far I have come up with the following using DATEPART and all data is in the same table (tables simplified): 1. When I insert records: INSERT INTO [Table] VALUES (newid(), @FKID, @Value, GETDATE()) 1. When I update records: UPDATE [Table] SET [Column] = @Value WHERE [FK] = @FKID AND (DATEPART(month, GETDATE()) = DATEPART(month, [TimeStamp])) 2. When I select records: SELECT * FROM [Table] WHERE [FK] = @FKID AND (DATEPART(month, GETDATE()) = DATEPART(month, [TimeStamp])) 3. WHEN I delete records: DELETE FROM [Table] WHERE [FK] = @FKID AND (DATEPART(month, GETDATE()) = DATEPART(month, [TimeStamp]))   Is this efficient? I was looking at partitioning, but I am not sure that it would be feasible as I want to recycle data every 12 months. Or is there a better way to do it? Regards, James

Is sharepoint good for storing relation data ?

Hi I would like to start discussion or find your opinion around "if sharepoint 2007 is a good platform to store relational data"? I found that quite often bussness doesn't feel that and push dev to create solution for relation data on top of sharepoint infrastructe. On the end we get huge customization with make everybody frustrated and those poor dev gays are blame for that. I believe that needs for relation data in particular solution draws clear line between apps build on top of Sharepoint or apps build with use of good old SQL database. Can I get your opinion around that ? I have three years expieriance with SharePoint and this is my personal opinion. If you could share your thoughts then for sure this would be helpfull for me and for other dev to show to the bussness why we somethimes suggesting them to go diffrent way. To build this discussion on some example let say that we need to build solution where: we have product table (with details around products) with contain two relation fields : user by country, owner by country we have country table (dictionary for countries), which contain field pointing to the region we have region table (dictionary for regions) we have few diffrents tables describing diffrent types of docs associated to products (like specyfication, safty documents, test documents) and let say there there goanna be a lot

Storing Data in database


Hi everyone,

I'm try to create a news site in my website. How can i store this kind of large text below in the database.

8 Questions Every Business Analyst Should Ask

It does not matter what project you are going to undertake. It is not important what industry you are going to be assessing. What is important is you know what you are going to do. You must as questions. You must find what it is the client wants. Presented is a list of obvious questions every good business analyst should know the answer to when starting a project.

1. What problem is this business having that you hope to solve by developing this project? It should be obvious as to why you would ask that question. If you do not understand what the problem is then you can not help to solve it. Also, when reading the project program it may not be clear as to what the client actually wants. The scope may only tell you what they would like to see happen. It could and often times is not focused on what the true issues are.

2. What is the business doing at present to alleviate or solve the issue? What has been tried in the past? You must understand what the client is doing in order to understand what mus

Weird casting error (storing Generic list in Session)


Am trying to store a generic list in Session to act as a simple shopping cart. Am getting a weird casting error when I try and retrieve it from Session.

A critical error has occurred.
[A]System.Collections.Generic.List`1[MyCartItem] cannot be cast to [B]System.Collections.Generic.List`1[MyCartItem].
Type A originates from 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\\mscorlib.dll'.
Type B originates from 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\\mscorlib.dll'.

I have a class variable defined:

List<MyCartItem> _cart;

In the Load event I have:

_cart = (Session["MyCart"] != null) ? (List<MyCartItem>)Session["MyCart"] : new List<MyCartItem>();

Retriving data from CheckBoxList and passing it to a Session



I wondering how can I retrive data from a CheckBoxList in c#. and once I get the data I would like to store the data in a session so I can use the data from a session on a another page

Thank you in advance

Data in session



I'm trying to work out what to do with some data I have which is used throughout a users session.

I need to hold up to 200 integers for a customer - not all customers will have 200, some may have none at all.

When I look at what this will consume in session, 1Gb of memory would be enough to support 2m users with full allocation. Even with an extremely busy site, say 1000 simultaneous users, memory would not be stretched.

With this in mind the obvious conclusion is to put the data in session, particularly as the tables data is retrieved from may contain 1m records.

The question I have is - is there anything else i need to consider - any hidden gremlins that I need to watch out for, or is it as simple as that?



Clearing Session Data from Modeless Popup window.


I am using Post method to generate crystal reports. The user requirement is to show the report in a modeless pop up screen. 

The session data needs to be cleared as it may at times contain a very large dataset.  

One implementation I have placed in at present is - placing a button "Close Button". When user clicks close button, I am able to clean up the session content as well as close the window.

The issue I am facing is to get the handle of the modeless window when it is closed using the x button. Also, since the pop up window is modeless, the user might have moved to another screen, henceforth the parent of the popup window is already changed or out of context.

How do we clear the sesssion content when the issue condition arises?

Please provide suggestions.

Storing configuration data



I'm developing an EventHandler that requires configuration data for each list.

I created  a CustomAction in List ViewToolbar and redirect users to a HandlerConfigurationPage.aspx. 

My question is, where can I save configuration data ?  One option is creating a hidden config.xml in the list and reading values from EventHandler. 


any ideas ? 






ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend