读书人

判断session,该怎么解决

发布时间: 2012-01-16 23:36:51 作者: rapoo

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

读书人网 >asp.net

热点推荐