473,386 Members | 1,973 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,386 software developers and data experts.

How to use variable instead of session

I use the following code in OnRowDataBound for getting the column sum
in a GridView:

Protected Sub dg(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Session("intAccountGroup") =
DataBinder.Eval(e.Row.DataItem, "AccountGroup")
End If

If e.Row.RowType = DataControlRowType.Footer Then
Dim txtSumB As TextBox =
CType(e.Row.FindControl("txtSumB"), TextBox)
txtSumB.Text = Generic_db.GetValue("SELECT Sum(Budget) FROM
vwOverview WHERE AccountGroup=" & Session("intAccountGroup") & " And
Positions=4")
End If
End Sub

I've been trying to replace the session value above with a variable but
it doesn't work because it doesn't contain any value for some reason. I
still have the feeling that there is some way to use a variable instead
of the session. Can someone please help me?

Regards,

S

Feb 22 '06 #1
1 1228
S, have you considered using Viewstate instead of session for this case?, if
you still have to use session do a function like this and see if that helps

Protected Sub SetSession(ByVal keyName As String, ByVal ObjectToStore As
Object)

Dim context As System.Web.HttpContext = System.Web.HttpContext.Current()

Dim state As System.Web.SessionState.HttpSessionState

state = context.Session()

If Not IsNothing(ObjectToStore) Then

state.Item(keyName) = ObjectToStore

End If

End Sub

Protected Function GetSession(ByVal keyName As String) As Object

Dim context As System.Web.HttpContext = System.Web.HttpContext.Current()

Dim sessionItem As Object = context.Session.Item(keyName)

GetSession = sessionItem

End Function

<st****@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I use the following code in OnRowDataBound for getting the column sum
in a GridView:

Protected Sub dg(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Session("intAccountGroup") =
DataBinder.Eval(e.Row.DataItem, "AccountGroup")
End If

If e.Row.RowType = DataControlRowType.Footer Then
Dim txtSumB As TextBox =
CType(e.Row.FindControl("txtSumB"), TextBox)
txtSumB.Text = Generic_db.GetValue("SELECT Sum(Budget) FROM
vwOverview WHERE AccountGroup=" & Session("intAccountGroup") & " And
Positions=4")
End If
End Sub

I've been trying to replace the session value above with a variable but
it doesn't work because it doesn't contain any value for some reason. I
still have the feeling that there is some way to use a variable instead
of the session. Can someone please help me?

Regards,

S

Feb 22 '06 #2

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

Similar topics

5
by: Ikke | last post by:
I have to share a variable between browser sessions. One session for example changes the variable, the other sessions must see the changes (get the new value instead of the original value) it's...
15
by: | last post by:
Hi, I want to do things this way: I have a bunch of stuff that I want to keep track of while a user is connected to the site. Maybe 50 little peices of information. So I know I can make 50...
0
by: Fie Fie Niles | last post by:
I posted a message yesterday in regard to session variable error message. Do you know what Microsoft DLL that processes Session variable? On that server, we can not seem to register anything....
1
by: S Olson | last post by:
I assume that mostly, asp programmers use their own session variable to know whether a user is to be considered is-logged-on (together with a home-written log-on form web page). However, I...
2
by: +The_Taco+ | last post by:
I already use session variable in my project to set a session timeout when the user doesn't do anything for 10 minutes. When I call other pages, I often use parameters in HREF link. I was...
3
by: Wayne Wengert | last post by:
I have an application where a session variable is set in an ASPX page, The process calls an ASP page and when in that page the session variable appears to be null. How can I pass a session variable...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
8
by: Jeff | last post by:
Still new to vb.net in VS2005 web developer... What is the proper/standard way of doing the following - setting the value of a variable in one sub and calling it from another? E.g., as below....
7
by: ADN | last post by:
Hi, I am creating a custom HTTPModule to intercept the request of when the user is attempting to retrieve a session variable. For instance, if I set a session variable in my code like so: ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...

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.