Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Session variable trouble

86 views
Skip to first unread message

arora...@gmail.com

unread,
Apr 13, 2006, 6:18:17 AM4/13/06
to
Hi,

I am facing a trouble. I have some Session variables in my code and
somehow my session variables are getting mixed up with other users.

For example User A has access to 10 companies and User B has access to
5, now when both of us hits to the server at the same time then their
session variables gets mixedup means either User A and USer B will have
now 5 companies or both have 10 companies. Now again when User A hits
to the server he will have again his session variables setting.

I have initialsed my session variables in session_Onstart event.
Now and clue why it is happening.

Regards,
Amit Arora

Paolo Marini

unread,
Apr 13, 2006, 7:19:52 AM4/13/06
to
Hi, how are you simulating the two different users? Same/differenr machine?
Same/different browser?


arora...@gmail.com

unread,
Apr 13, 2006, 7:23:38 AM4/13/06
to
diffrent machine and diffrent browser...

arora...@gmail.com

unread,
Apr 13, 2006, 7:23:51 AM4/13/06
to
diffrent machine and same browser...

Hans Kesting

unread,
Apr 13, 2006, 8:05:24 AM4/13/06
to

By any chance using *static* members in those objects that you put in
session?

Hans Kesting


arora...@gmail.com

unread,
Apr 13, 2006, 8:17:23 AM4/13/06
to
Nopes, infact earlier I was using static variables but later on I
changed it to Sessions.........

Patrice

unread,
Apr 13, 2006, 10:01:46 AM4/13/06
to
Have you checked that you don't store a static variable in your session
objet ? What matters is not really that you use session variables, but
rather what exactly you store in those session variables.

It should be fairly easy to repro the problem or not with just a small piece
of code so that you can make sure it works in the trivial case. From there
you'll make sure if this is a problem in your code (I would expect this) or
if you have really a big problem with sessions.
--
Patrice

<arora...@gmail.com> a écrit dans le message de news:
1144930643.7...@g10g2000cwb.googlegroups.com...

arora...@gmail.com

unread,
Apr 13, 2006, 10:43:16 AM4/13/06
to
Patric Here goes my long code, if you could check it out, then I would
be more than obliged to you...................

namespace CMS
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using Properties;
//using UserContorls;

/// <summary>
/// Summary description for DisplayCompanyContacts.
/// </summary>
public class DisplayCompanyContacts : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.PlaceHolder plcompany;
LiteralControl litcontrol;
protected System.Web.UI.WebControls.CheckBox CheckBox1;
LiteralControl litcontrol2;
string roleid,userid;
protected System.Web.UI.WebControls.Button btn;
protected System.Web.UI.WebControls.LinkButton ClearLink;
protected System.Web.UI.HtmlControls.HtmlInputHidden CheckBoxFlag;
protected System.Web.UI.HtmlControls.HtmlInputHidden CompanyID;
protected System.Web.UI.WebControls.LinkButton SelectLink;

private void Page_Load(object sender, System.EventArgs e)
{
//DisplayConversationFromCalander();
if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="";
roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();
//if(!IsPostBack)
bindleftpanel();


///Removing these Common Properties and Placing Sessions Instead

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

/* if(CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Length>0)
CommonProperties.CompaniesCheckBoxIDsInLeftMenu=
CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Substring
(0,CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Length-1);

if(CommonProperties.ContactCheckBoxIDsInLeftMenu.Length>0)
CommonProperties.ContactCheckBoxIDsInLeftMenu=
CommonProperties.ContactCheckBoxIDsInLeftMenu.Substring
(0,CommonProperties.ContactCheckBoxIDsInLeftMenu.Length-1); */

/* if (Request.Url!=null)
{
string _pageurl=Request.Url.ToString();
char[] splitter = {'/'};
string[] arInfo = _pageurl.Split(splitter);
for(int x = 0; x < arInfo.Length; x++)
{
_pageurl=arInfo[x];
}

if (_pageurl=="ViewContact.aspx")
{
UserContorls.ViewContact viewcontact=new
CMS.UserContorls.ViewContact();
viewcontact.BindViewDetails();
}
} */
}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
//string sql;
/*if (roleid=="1" || roleid=="2")
{
if (CommonProperties.FilterCompanyId==null)
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+roleid+" Union Select Company_id from Company where
COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') and
company_id='"+CommonProperties.FilterCompanyId.ToString()+"' order by
company_name";
}
}
else
{
sql="select * from company order by company_name";
}*/
//objcomm=new SqlCommand(sql,strcon);

//kapil kalra 20-mar-2006 permission check
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);*/
try
{
objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Session["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
}
catch
{}
objread=objcomm.ExecuteReader();
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="";
//Session["CompaniesCheckBoxIDsInLeftMenu"]="";
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();
//Response.Write(objread["company_id"]);
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(this);");
chkbox.EnableViewState=true;
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu+=chkbox.ID+",";
Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString()!="" )
{
//string info_company =
CommonProperties.SelectedCompany;
string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();
//string sql2;

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );
/* objcomm2.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
objcomm2.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
objcomm2.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
objcomm2.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);*/

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//Session["ContactCheckBoxIDsInLeftMenu"]="";
if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();
//CommonProperties.ContactCheckBoxIDsInLeftMenu+=chkbox.ID+",";
Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;
//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
//string info_company =
CommonProperties.SelectedContact;
string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();

if(roleid=="4" ||roleid=="5"||roleid=="6"||roleid=="7" )
{
int flag=ColorSeg(company_id,objread2["contact_id"].ToString());

if(flag==0)//not alloted
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==1)//alloted to RA
{
litcontrol2.Text="<span
class=FilterListContactRA>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==2)// alloted to SR
{
litcontrol2.Text="<span
class=FilterListContactSR>"+objread2["contact_name"].ToString()+"</span><br>";
}
else// alloted to both
{
litcontrol2.Text="<span
class=FilterListContactBoth>"+objread2["contact_name"].ToString()+"</span><br>";
}

}
else
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}

plcompany.Controls.Add(litcontrol2 );
}
}


objcomm2.Cancel();
objread2.Close();
strcon2.Close();
}
}

private int ColorSeg(string company_id,string contactid)
{
int flag=0;
string kk;
string sql="SELECT userroleid FROM
dbo.CONTACTSALLOCATION where CONTACT_ID="+contactid+" and userroleid
in(1,2)";
SqlConnection conn=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]);
SqlCommand cmd=new SqlCommand();
cmd.Parameters.Clear();
cmd.CommandText="dbo.[Usp_LeftPanelColor]";
cmd.CommandType=CommandType.StoredProcedure;
cmd.Connection=conn;
cmd.Parameters.Add("@contactid",Convert.ToInt32(contactid));

DataSet ds=new DataSet();
SqlDataAdapter adpter=new SqlDataAdapter(cmd);

adpter.Fill(ds);

if(ds.Tables[0].Rows.Count>0)
{
kk= ds.Tables[0].Rows[0]["userroleid"].ToString();
flag=Convert.ToInt32(kk);
if(ds.Tables[0].Rows.Count>1)
{
flag=3;
}
}
return flag;

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SelectLink.Click += new
System.EventHandler(this.SelectLink_Click);
this.ClearLink.Click += new
System.EventHandler(this.ClearLink_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void ASSIGN_CHECKED(object sender, System.EventArgs e)
{
//CommonProperties.SelectedCompany=null;
Session["SelectedCompany"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if (roleid=="1" || roleid=="2")
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company order by company_name";
}

objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/*objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);

objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcompany"+objread["company_id"].ToString());

string _unchkdcompanyid=check.ID;
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString().Trim()!="" )
{

//CommonProperties.SelectedCompany=CommonProperties.SelectedCompany+","+_chkdcompanyid;
Session["SelectedCompany"]=Session["SelectedCompany"]+","+_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
else
{
//CommonProperties.SelectedCompany=_chkdcompanyid;
Session["SelectedCompany"]=_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
}
else
{
// UnChkContatct(_unchkdcompanyid);
}


}
}
if(Session["SelectedCompany"].ToString().StartsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(1,Session["SelectedCompany"].ToString().Length);
}
if(Session["SelectedCompany"].ToString().EndsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(0,Session["SelectedCompany"].ToString().Length-1);
}
if(Session["SelectedContact"].ToString().StartsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(1,Session["SelectedContact"].ToString().Length);
}
if(Session["SelectedContact"].ToString().EndsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(0,Session["SelectedContact"].ToString().Length-1);
}
objcomm.Cancel();
objread.Close();
}
string FlagStatus=CheckBoxFlag.Value.ToString();

string strCompanyID=CompanyID.Value.ToString();
strCompanyID=strCompanyID.Substring(strCompanyID.LastIndexOf("_")+1);


if(!Convert.ToBoolean(FlagStatus))
UnChkContatct(strCompanyID);


}

public void ChkContact(string chkedCmpy)
{

chkedCmpy=chkedCmpy.Replace("chkcompany","");


SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();
// SqlCommand cmdcontact=new SqlCommand("Select CONTACT_ID from
Contacts where CONTACT_COMPANY_ID='"+chkedCmpy+"'", conn);
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);*/

cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);

cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();

if(rdr.HasRows)
{
while(rdr.Read())
{

CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());
check.Checked=true;


string _chkdcontactid=check.ID;


//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
int flag=AldyInsertCont(_chkdcontactid);
if(flag==0)
//CommonProperties.SelectedContact=CommonProperties.SelectedContact+","+_chkdcontactid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcontactid;
}
else
{
//CommonProperties.SelectedContact=_chkdcontactid;
Session["SelectedContact"]=_chkdcontactid;
}
}
}

}

private int AldyInsertCont(string contid)
{
int flag=0;
string[] Cont=Session["SelectedContact"].ToString().Split(new char[]
{','});
for(int i=0;i<Cont.Length;i++)
{
if(contid==Cont[i].ToString())
{
flag=1;
break;
}

}
return flag;
}

public void UnChkContatct(string chkedCmpy)
{

string chkedCmpy1=chkedCmpy;
chkedCmpy=chkedCmpy.Replace("chkcompany","");
SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Clear();
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);*/


cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);


cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();


// string[] ChkContacts=CommonProperties.SelectedContact.Split(new
char[] {','});
// CommonProperties.SelectedContact=null;
if(rdr.HasRows)
{
while(rdr.Read())
{
CheckBox check1 = (CheckBox)plcompany.FindControl(chkedCmpy1);


CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());


//if(CommonProperties.SelectedContact!=null)
if(Session["SelectedContact"].ToString()!="")
{
/* if(CommonProperties.SelectedContact.IndexOf(check.ID.ToString()+",")>-1)
CommonProperties.SelectedContact=CommonProperties.SelectedContact.Replace(check.ID.ToString()+",","");
else
if(CommonProperties.SelectedContact.IndexOf(check.ID.ToString())>-1)
CommonProperties.SelectedContact=CommonProperties.SelectedContact.Replace(check.ID.ToString(),"");*/
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString()+",")>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString()+",","");
else
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString())>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString(),"");


}


// CommonProperties.SelectedContact=null;


check.Checked=false;
}


}

}


public void Contact_Checked(object sender, System.EventArgs e)
{
// CommonProperties.SelectedContact=null;
Session["SelectedContact"]="";


using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if ( roleid=="2")
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+")
order by contact_name";
}
else if(roleid=="1" )
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+"
Union Select CONTACT_ID from Contacts where contact_company_id in
(select COMPANY_ID from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"'))) order by contact_name";
}
else
{
sql="select * from contacts order by contact_name";
}

//Response.Write (sql);
//Response.End();
objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Contact_Checked",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );

objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);
objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid);
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompanyId);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.FilterIV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDomain);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSource);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkType);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDisposition);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesignation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail);
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone);*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);


objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+objread["contact_id"].ToString());
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
// if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
// CommonProperties.SelectedContact=CommonProperties.SelectedContact+","+_chkdcompanyid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcompanyid;
}
else
{
//CommonProperties.SelectedContact=_chkdcompanyid;
Session["SelectedContact"]=_chkdcompanyid;
}
}

}
}
objcomm.Cancel();
objread.Close();
}
}

private void SelectLink_Click(object sender, System.EventArgs e)
{
CheckAllCompaniesContact();
}
private void CheckAllCompaniesContact()
{
try
{
// string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"];
}
catch{}
try
{
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBoxIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
// CommonProperties.SelectedCompany=CommonProperties.CompaniesCheckBoxIDsInLeftMenu;
// CommonProperties.SelectedContact=CommonProperties.ContactCheckBoxIDsInLeftMenu;

Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"];
}
catch{}
}

private void ClearLink_Click(object sender, System.EventArgs e)
{
ClearAllCompaniesContact();
}
private void ClearAllCompaniesContact()
{
try
{
//string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBoxIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}

//CommonProperties.SelectedCompany=CommonProperties.CompaniesCheckBoxIDsInLeftMenu="";

//CommonProperties.SelectedContact=CommonProperties.ContactCheckBoxIDsInLeftMenu="";
Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"]="";
}
catch{}
}


}
}

Ray Booysen

unread,
Apr 13, 2006, 11:46:28 AM4/13/06
to
Ummm, no one is going to read this. Can you please attach the code that
is causing the problem?

arora...@gmail.com

unread,
Apr 13, 2006, 11:55:06 AM4/13/06
to
Well, the problem is this code only...............

If you could solve it then please seee...

Jeff Dillon

unread,
Apr 13, 2006, 1:14:42 PM4/13/06
to
No. Reduce the code to show the problem. Create a test.aspx page that
minimully demonstrates the problem

Jeff

<arora...@gmail.com> wrote in message
news:1144943706....@t31g2000cwb.googlegroups.com...

arora...@gmail.com

unread,
Apr 13, 2006, 2:42:17 PM4/13/06
to
Here is the Minimal code, Here I have included 3 methods, as Page_Load,
BindLeftPanel (Which actaully Binds the Companies Check Boxes),
SubContact (Which is called for each company with companyID) and
fetches out concerned Contacts with companyID paased as parameter.
Apart from this we have Assign_Checked event method which is called
when we click on a check box.

Please see if any thing is possible..........


private void Page_Load(object sender, System.EventArgs e)
{

if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";

roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();

bindleftpanel();

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

}

public void bindleftpanel()


{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );

if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();

chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(this);");
chkbox.EnableViewState=true;

Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";


if (Session["SelectedCompany"].ToString()!="" )
{

string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();

int permission=0;


if((CommonRules.CommonLogic.isValidServiceItem(Convert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);


objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();


if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();

Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

if (Session["SelectedContact"].ToString()!="")
{

string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();

Jeff Dillon

unread,
Apr 13, 2006, 3:20:53 PM4/13/06
to
Way too much code again! Remove all sql code, and get it down to a dozen
lines or so of code! Just hard code the equivalent database values

Jeff

<arora...@gmail.com> wrote in message
news:1144953737.4...@z34g2000cwc.googlegroups.com...

Russell

unread,
Apr 14, 2006, 9:09:24 AM4/14/06
to
At a wild guess, a bug in your stored procedure Usp_LeftMenu_Contact,
perhaps it isn't actually querying the user id? You should explicitly
execute it with different values and observe the results.

You might put some handling in your catch block too, although I'd
expect the subsequent call to ExecuteReader to fail if the parameters
aren't initialized.

Patrice

unread,
Apr 14, 2006, 10:01:04 AM4/14/06
to
Also dump userid and sessionid so that you can at least cut down the mixed
up session theory.
If you have the same userid but distinct sessionIDs this is that the userid
initialization code is likely bad.
Also SQL Server profiler may help (you'll see if both statement are fed with
the same parameters for both users, you can try them from QA then).

My failed attempt was to convey the idea that to find out the problem you
have to try and test hypothesis on possibly simplified code instead of
trying to address the problme in the whole original context where likely
much of the code has nothing to do with the carrefully hidden problem.

--
Patrice

"Russell" <rus...@goisc.com> a écrit dans le message de news:
1145020164....@u72g2000cwu.googlegroups.com...

0 new messages