468,545 Members | 1,873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,545 developers. It's quick & easy.

Global variable not keeping value

tfs
I have a variable I am trying to keep the values in and I have it set
as a global variable.

<script runat="server">

Dim saveCommandText as String

Sub SortDataGrid (sender as Object, e as
DataGridSortCommandEventArgs)

response.Write("Before setting saveCommandText = "
& saveCommandText & "<p>")
If saveCommandText = "" then
saveCommandText = DataSet1.CommandText
End if
response.Write("After setting saveCommandText = " &
saveCommandText & "<p>")
DataSet1.CommandText = saveCommandtext & " order by
" & e.SortExpression

end Sub
</script>
saveCommandText gets set, but when I go to SortDataGrid after a button
is pushed, saveCommandText is blank again.

Why is this? Doesn't the system keep these variables values?

Thanks,

Tom.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #1
1 1475

"tfs" <tf*@dslextreme-dot-com.no-spam.invalid> wrote in message news:40**********@Usenet.com...
I have a variable I am trying to keep the values in and I have it set
as a global variable.

<script runat="server">

Dim saveCommandText as String

[snip]
This variable is global (meaning: available in all subs and functions)
for *this instance* of this page. As soon as the request is
finished, the variable becomes unavailable.

If you want this value to be available to the entire application (every user
sees the same value), store it in the Application object.
If every user should have his/her own value, use Session.

Hans Kesting
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

88 posts views Thread by Tim Tyler | last post: by
8 posts views Thread by David Hitillambeau | last post: by
5 posts views Thread by Nathan Bloomfield | last post: by
9 posts views Thread by Shapper | last post: by
112 posts views Thread by istillshine | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.