zoukankan      html  css  js  c++  java
  • 小问题,小细节要注意(string类型转换为bool类型)

    一个表中的推荐字段是bit类型的,添加的时候推荐有两个值,如
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
    <asp:ListItem Text="是" Value="1"></asp:ListItem>
    <asp:ListItem Text="否" Value="0" Selected="True"></asp:ListItem>
    </asp:RadioButtonList>
    那么修改的时候要想得到选中项,就要做好判断了。先前,一直在用 RadioButtonList1.SelectValue= dt.Rows[0]["tuijian"].ToString();来
    取值,但是这样是取不到值的,因为打印dt.Rows[0]["tuijian"].ToString()发现得到的是true或者false,此时就需要判断和转换了。


    if (Convert.ToBoolean(dr["tuijian"].ToString()) == true) //将string类型转换为bool类型
    {
           RadioButtonList1.SelectValue = "1";
    }
    else
    {
           RadioButtonList1.SelectValue = "0";
    }

  • 相关阅读:
    移动端picker插件
    腾讯云主机如何使用root账号登录,不能使用root登录怎么办
    windows安装composer总结
    ubuntu安装git
    workman
    权限设计
    app接口
    git提交流程简述
    mysql分区partition详解
    html元素拖拽
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/4410460.html
Copyright © 2011-2022 走看看