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

Global Variable for URL param recommendation

Rob
Please recommend best practice for adding a global
variable to an ASP.net class that will take on a
Request.Params("") value from the URL calling the aspx
page to be used throughout in stored procedure calls as a
parameter in datagrids.

Currently, the best I came up with was to add code around
the Web Form Designer code of the Select statement that
defines the variable and sends it as a Parameter to the
stored procedure. However, Visual studio keeps
overwriting this code everytime I use the GUI tools on the
data objects. Using variable in Select Stored Procedure
paramater call in the Value area.

Is there a better/easier way to send the variable in the
GUI "control source" or value for the data adapter select
statement sp call?

Thank you,

Rob

----
'
'SqlSelectCommand1
'
'RW - Attempt to globally define EmployeeID from
URL paramater for stored procedure
If Not (Request.Params("EmployeeID") Is Nothing)
Then
EmployeeID = Int32.Parse(Request.Params
("EmployeeID"))
Else
EmployeeID = "302"
End If
'/RW
Me.SqlSelectCommand1.CommandText
= "[spGetEmpAttach]"
Me.SqlSelectCommand1.CommandType =
System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE" ,
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.ReturnValue, False, CType
(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
'RW
Me.SqlSelectCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@EmployeeID",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0,
Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, EmployeeID))
'/RW
Jul 19 '05 #1
1 1890
Hi Rob,

I think you could store the variable in a session or application state. So
you could get it throughout the web application.

For an example:
Session["EmployeeID"] = EmployeeID;
Application["EmployeeID "] = EmployeeID;

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
Jul 19 '05 #2

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

Similar topics

6
by: Loopy | last post by:
I'm learning XML and XSL at the moment, but I still can't get my head around the concept of non-updatable variables. I know we can use recursion to cycle through a data structure and get the sum...
0
by: Eshrath Khan | last post by:
Hi all, I have a .Net program which access transforms a XML using an XSL stylesheet. The .net program calls Stylesheet main.xsl file. The main.xls contains only <xsl:include> elements to...
1
by: Eshrath Khan | last post by:
Hi all, I have a .Net program which access transforms a XML using an XSL stylesheet. The .net program calls Stylesheet main.xsl file. The main.xls contains only <xsl:include> elements to...
5
by: sworna vidhya | last post by:
Hai, When viewing threads of comp.lang.c, I came across with 'static const char * const resultFileName = "param.txt";' . Here in this thread, 'static const char * const resultFileName =...
1
by: Rob Wire | last post by:
Please let me know the preferred way to do the following. Accept a Variable in the calling page's URL of an ID. Set that variable to be global scope of the class so that it can be used throughout...
2
by: Rob | last post by:
Please recommend best practice for adding a global variable to an ASP.net class that will take on a Request.Params("") value from the URL calling the aspx page to be used throughout in stored...
12
by: a | last post by:
def fn(): for i in range(l) global count count= .... how do i declare count to be global if it is an array subsequently i should access or define count as an array error:
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
18
by: Bruce | last post by:
When I do this: <input id="someName" type="text"> <script type="text/javascript"> alert(someName.nodeName); </script> Both IE6 and Firefox alert("INPUT"). Why isn't "someName" undefined?
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.