如题:
相关代码public class UserModel{
privter int _userIsStop;
public int userIsStop{
get{return _userIsStop;}
set{_userIsStop=value;}
}
}
Model.UserModel userInfo = new Model.UserModel ();
userInfo.userIsStop = int.Parse(e.CommandName);CommandName 为repeater模版列中LinkButton控件的CommandName 值为"True" 或 "False"

解决方案 »

  1.   

    只有数字类型的string才能转成int,true怎么转?
      

  2.   


    e.CommandName == "True"?1:0
      

  3.   


    userInfo.userIsStop =e.CommandName == "True"?1:0
      

  4.   


    userInfo.userIsStop =e.CommandName == "True"?1:0
      

  5.   


    userInfo.userIsStop =e.CommandName == "True"?1:0
      

  6.   

    这不是C++    C#是有强类型检查的 INT和BOOL  不能混用  BOOL 可不是 0或1的表示必须用判断。
      

  7.   


            public static int String2Integer(string str)
            {
                return str == "True" ? 1 : 0;
            }
      

  8.   

    userInfo.userIsStop = (e.CommandName=="True"?1:0);
      

  9.   

    还是无法将类型“int”隐式转换为“bool  这样的错误
      

  10.   

    CommandName 值为"True" 或 "False"??为啥?
      

  11.   

    CommandName='<%# DataBinder.Eval(Container.DataItem, "SFL_UserIsStop") %>'
    SFL_UserIsStop 为 bit 型
      

  12.   

    C#是强类型语言,int型的当然不能转换成bool型
    如果一定要用,写一个if语句判断一下。
    if (CommandName.ToString().ToLower() == "true")
        return 1;
    else
         return 0;int.Parse可以转换数值类型的字符串,如:int.Parse("12");而int.Parse("True")肯定抛异常。
      

  13.   

     我觉得楼主出错的地方不是你出示代码的地方
    而是不知道在哪里 把字段SFL_UserIsStop的值转换成bool值出错了。