日期:2014-05-19  浏览次数:20470 次

判断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= '管理员 ' ";
}
}