我的前台有个DropDownList ,后台我通过 string xibie=DropDownList1.SelectedValue来获取前台DropDownList所选中的值
现在我想这样实现
try
{
if(xibie='全院 ')
{
string str="select * from jieguo order by total desc";
}
else
{
string str = "select * from jieguo where dept='"+xibie+"' order by total desc";
}
}
catch(Exception)
{
throw;
}
前台DropDownList里有一些系的选项:信息工程系、管理系、外语系.....我想再加一个所有系(全院)的
可是后台那样写try catch 的时候提示:字符文本中的字符太多,估计是需要把xibie给类型转换一下吧,求解!
现在我想这样实现
try
{
if(xibie='全院 ')
{
string str="select * from jieguo order by total desc";
}
else
{
string str = "select * from jieguo where dept='"+xibie+"' order by total desc";
}
}
catch(Exception)
{
throw;
}
前台DropDownList里有一些系的选项:信息工程系、管理系、外语系.....我想再加一个所有系(全院)的
可是后台那样写try catch 的时候提示:字符文本中的字符太多,估计是需要把xibie给类型转换一下吧,求解!
if(xibie='全院 ')
改成
if(xibie="全院")
应该是这样吧
if(xibie=="全院")
两个"=="哦。
if(xibie='全院 ')
改成
if(xibie.Trim()=='全院 ')注意: = 是赋值运算符
==是比较相等运算符
这样的错误要避免哦!
系目录应该用 数据库存放。尽量不要在UI中设定。