Please find the code snippets below:
Method A inside User Control A:
-------------------------------------------
public void LoadDataGrid()
{
DataSet ds = new DataSet();
string[] sqlString = new string[2];
sqlString[0] = " SELECT REQ_CLIENT.ID,F IRSTNAME ||' '|| LASTNAME
NAME,COMPANY,CO UNTY, "+ " DECODE(REQ_CLIE NT.ID,BILLING_C ONTACT,1,0)
IS_BILLING_PERS ON "+ " FROM REQ_CLIENT,REQ_ QUEUE WHERE "+
" REQ_QUEUE.ID = ID_REQ_QUEUE AND "+" ID_REQ_QUEUE=
"+Session["ID_REQ_QUE UE"].ToString()+" ORDER BY UPPER(LASTNAME) ";
.........
.........
.........
-------------------------------------------------
The way I am calling the User Control A from Control B is as follows by
instantiating an object of the Control class:
secure.NewDiagn ostics.Requeste r.Contacts1 parentControl = new
secure.NewDiagn ostics.Requeste r.Contacts1();
if(this.Parent! =null)
{
parentControl.L oadDataGrid();
}
So when control goes back to the LoadDataGrid method in the parent control I
get the following error:
ErrorMessage:
----------------
Object reference not set to an instance of an object.
ErrorSource: System.Web
ErrorTargetSite :
----------------
System.Web.Sess ionState.HttpSe ssionState get_Session()
ErrorTrace:
----------------
at System.Web.UI.U serControl.get_ Session()
at secure.NewDiagn ostics.Requeste r.Contacts1.Loa dDataGrid() in
c:\inetpub\wwwr oot\intranet.pd is.org\diagnost ics\submitter\c ontacts1.ascx.c s:line 522
At line 522, there is an SQL query which is accessing a session variable.
Any pointers?
Thanks!!
"Steve C. Orr [MVP, MCSD]" wrote:
Please show us the line of code that is causing the error message and give
us the error message.
--
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Diffident" <Di*******@disc ussions.microso ft.com> wrote in message
news:4F******** *************** ***********@mic rosoft.com...Hello All,
I have a nested user control i.e., Control B which is loaded from Control
A.
Control A is itself dynamically loaded from a web form.
Control A has a "Save" button which loads the Control B dynamically. Now
in
Control B there is a "Return" button which calls the method A of Control
A.
In method A, a session variable is being retrieved. My problem is whenever
the control is passed back to the Control A, error is being thrown at the
line where session is being retrieved.
Can anyone please suggest me on how to go about this problem? Is there any
other way to access session from user controls?
Thanks for your pointers!!!