zoukankan      html  css  js  c++  java
  • checkbox修改功能保存功能绑定

    <td> login_type</td>
    <td>
    <input type="checkbox" name="txt_login_type" id="txt_login_type" value="Crm" runat="server" />Crm &nbsp;
    <input type="checkbox" name="txt_login_type1" id="txt_login_type1" value ="Log" runat="server"/>Log &nbsp;
    <input type="checkbox" name="txt_login_type2" id="txt_login_type2" value="Innoways" runat="server" />Innoways &nbsp;
    <input type="checkbox" name="txt_login_type3" id="txt_login_type3" value="CS" runat="server"/>CS &nbsp;
    </td>
    <td><input type="checkbox" name="txt_login_type4" value="Account_manager" id="txt_login_type4" runat="server"/>Account_manager &nbsp;

    <%--<input name="txt_Logintypes" type="text" value="" maxlength="30" id="txt_Logintypes" class="textboxcontent" runat="server" />--%>
    </td>

    CS ,Account_manager,Log,Crm

    绑定数据checkbox字符 Split返回的字符串进行分割
    string[] Array = model.login_type.Split(',');

    for (int i = 0; i < Array.Length; i++)
    {
    if (Array[i].Equals(txt_login_type.Value.Trim()))
    {
    txt_login_type.Checked = true;
    }
    if (Array[i].Equals(txt_login_type1.Value.Trim()))
    {
    txt_login_type1.Checked = true;

    }
    if (Array[i].Equals(txt_login_type2.Value.Trim()))
    {
    txt_login_type2.Checked = true;
    }
    if (Array[i].Equals(txt_login_type3.Value.Trim()))
    {
    txt_login_type3.Checked = true;
    }
    if (Array[i].Equals(txt_login_type4.Value.Trim()))
    {
    txt_login_type4.Checked = true;
    }
    }

    更新保存数据

    model.login_type = "";
    if (txt_login_type.Checked)
    {
    model.login_type += txt_login_type.Value.Trim() + ",";
    }
    if (txt_login_type1.Checked)
    {
    model.login_type += txt_login_type1.Value.Trim() + ",";
    }
    if (txt_login_type2.Checked)
    {
    model.login_type += txt_login_type2.Value.Trim()+",";
    }
    if (txt_login_type3.Checked)
    {
    model.login_type += txt_login_type3.Value.Trim()+",";
    }
    if (txt_login_type4.Checked)
    {
    model.login_type += txt_login_type4.Value.Trim()+',';
    }
    Substring 截取字符串
    model.login_type = model.login_type.Substring(0, model.login_type.Length - 1);

     

  • 相关阅读:
    Sqlserver日期函数应用
    SSRS匿名访问
    SSAS动态添加分区(一)
    BI就是报表?
    CreateEvent函数/多线程/c++
    字符编码介绍
    Win7 64下Visual C++ 6.0不兼容
    Winpcap安装,Cannot open include file 'pcap.h'
    PPT开发 * .pps 文件类型
    Visual Assist X 工具栏不显示 toolbar
  • 原文地址:https://www.cnblogs.com/linnew/p/10640737.html
Copyright © 2011-2022 走看看