首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

判断session,该怎么解决

2012-01-16 
判断sessionif(HttpContext.Current.Session[ Type ].ToString()管理员 ){SqlDataSource1.SelectCom

判断session
if   (HttpContext.Current.Session[ "Type "].ToString()   ==   "管理员 ")
                {
                        SqlDataSource1.SelectCommand   =   "select   *   from   userinfo   where   UType= '会员 ' ";
                }
  if   (HttpContext.Current.Session[ "Type "].ToString()   ==   "系统管理员 ")
                {
                        SqlDataSource1.SelectCommand   =   "select   *   from   userinfo   where   UType= '会员 '   or   UType= '管理员 ' ";
                }
以上代码在判断的时候出现错误请指教!多谢!!

[解决办法]
if(HttpContext.Current.Session[ "Type "]!=null)
{
if (HttpContext.Current.Session[ "Type "].ToString() == "管理员 ")
{
SqlDataSource1.SelectCommand = "select * from userinfo where UType= '会员 ' ";
}
if (HttpContext.Current.Session[ "Type "].ToString() == "系统管理员 ")
{
SqlDataSource1.SelectCommand = "select * from userinfo where UType= '会员 ' or UType= '管理员 ' ";
}
}

热点排行