zoukankan      html  css  js  c++  java
  • GridView中显示bool字段(在数据库中是字符类型)

    法一:

    <asp:BoundField DataField="是否启用" HeaderText="是否启用">
       <ItemStyle Width="15%" HorizontalAlign="Center" />
    </asp:BoundField>

            if (ds != null && ds.Tables[0].Rows.Count > 0) // 进行数据绑定前的示意转换
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["是否启用"].ToString() == "1")
                        ds.Tables[0].Rows[i]["是否启用"] = "是";
                    else
                        ds.Tables[0].Rows[i]["是否启用"] = "否";
                }
            }

    法二:

    <asp:TemplateField HeaderText="是否启用">
       <ItemTemplate>
       <asp:CheckBox runat="server" ID="chkSFQY" Enabled="false"></asp:CheckBox>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" Width="15%" />
     </asp:TemplateField>

     protected void gvMenuList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                

                if (((DataRowView)e.Row.DataItem).Row["是否启用"].ToString() == "1")
                {
                    ((CheckBox)e.Row.FindControl("chkSFQY")).Checked = true;
                }
                else
                {
                    ((CheckBox)e.Row.FindControl("chkSFQY")).Checked = false;
                }
            }

    }

  • 相关阅读:
    慕课网 k8s环境搭建坑点
    这种yum源为阿里云
    linux yum安装jdk
    docker 常用命令
    docker部署
    docker windows安装 就是这么简单
    idea
    jrebel 破解失败 Unexpected response from server
    bladex flowable 表关系
    bladex 接口
  • 原文地址:https://www.cnblogs.com/chengpeng/p/2277532.html
Copyright © 2011-2022 走看看