zoukankan      html  css  js  c++  java
  • listbox 多选删除(找了好多都不行,终于让我写出来了)

    方法一:两个for循环

    aspx.cs

    private string id="";
    protected void btn_del_Click(object sender, EventArgs e)
    {

    for (int i = 0; i < typeList.Items.Count; i++)
    {
    if (typeList.Items[i].Selected)
    {
    id += typeList.Items[i].Value + ",";
    //id = string.Format("{0}{1},", id, typeList.Items[i].Value);
    }
    }
    id = id.Substring(0, id.Length - 1); //去掉最后一个“,”
    string[] arr = id.Split(',');
    for (int j = 0; j < arr.Length; j++)
    {
    int ii = Convert.ToInt32(arr[j]);
    B_MessageType.deleteMessageType(ii);
    }
    gettype();
    }

    方法二:少见的GetSelectedIndices();

    aspx.cs

    bool proper_selected = false;
    main_tips_container.Visible = false;
    if (lbTypeList.Items.Count > 0 )
    {

    int[] selTypes = lbTypeList.GetSelectedIndices();

    if (selTypes.Length > 0 )
    {
    proper_selected = true;
    for (int c = 0; c < selTypes.Length; c++)
    {
    string str_card_id = lbTypeList.Items[selTypes[c]].Value;
    int type_id = MyNumber.getInt(str_card_id);
    B_MessageType.deleteMessageType(type_id);

    }
    LoadTypeList();
    }
    }

    if (proper_selected == false)
    {
    main_tips_container.Visible = true;
    main_tips_body.InnerHtml = "Please check your type selection again !";
    }

    多多指教!

  • 相关阅读:
    Selenium2+python自动化17-JS处理滚动条
    图论一
    HDU1106
    银行家算法学习笔记
    NYOJ 540
    我在博客园 2013-08-02 22:04 200人阅读 评论(0) 收藏
    编程之美:平面最近点对
    RIA算法解决最小覆盖圆问题
    求两直线交点和三角形内外心
    求圆心
  • 原文地址:https://www.cnblogs.com/suan1717/p/6215076.html
Copyright © 2011-2022 走看看