当前位置: 代码迷 >> ASP.NET >> 判断session,该怎么解决
  详细解决方案

判断session,该怎么解决

热度:5593   发布时间:2013-02-26 00:00:00.0
判断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= '管理员 ' ";
}
}
  相关解决方案