• checkListbox的使用


     
     <asp:CheckBoxList ID="ddMaterial"    runat="server">
                                                </asp:CheckBoxList>
     
     为checklistbox绑定list
      TbSortMaterialList designerList = TbSortMaterial.GetTbSortMaterialListNoPage();

                for (int i = 0; i < designerList.Count; i++)
                {
                    string text = designerList[i].MaterialName;
                    string value = (designerList[i].MaterialId).ToString();
                    ddMaterial.Items.Add(new ListItem(text, value));
                }
     
     
     
     从数据库查出选中显示时,在数据库里保存形式是以逗号隔开的value
     string[] arr = tgobj.ProductMaterial.Split(',');
                for (int i = 0; i < arr.Length-1; i++)
                {
                    for (int J = 0; J < ddMaterial.Items.Count; J++)
                    {
                        if (ddMaterial.Items[J].Value == arr[i].ToString())
                        {
                            ddMaterial.Items[J].Selected = true;
                        }
                    }
                   
                }
               
               
               
               
     修改提交保存时
     
       string material ="";
                for (int i = 0; i < ddMaterial.Items.Count; i++)
                {
                    if (ddMaterial.Items[i].Selected)
                    {
                        material += ddMaterial.Items[i].Value + ",";
                    }
                }

  • 相关阅读:
    BZOJ 2055 80人环游世界 有上下界最小费用可行流
    BZOJ 2406 LuoguP4194 矩阵 有上下界可行流
    BZOJ4873 LuoguP3749 寿司餐厅
    51nod 1551 集合交易 最大权闭合子图
    BZOJ 1565 植物大战僵尸 最大权闭合子图+网络流
    [CodeForces]460C Present
    [BZOJ5072] 小A的树
    [TJOI2015]组合数学
    [HNOI2006]鬼谷子的钱袋
    [IOI2007]矿工配餐
  • 原文地址:https://www.cnblogs.com/jimmychow/p/2287106.html
Copyright © 2020-2023  润新知