zoukankan      html  css  js  c++  java
  • 解决asp.net中listbox的SelectedIndex的取值为1

    protected void Page_Load(object sender, System.EventArgs e)
     {

    ...

                    string[] maindir = stypes.Split(new char[] { ',' });
                    for (int i = 0; i < maindir.Length; i++)
                    {
                        lbclasss.Items.Add(new ListItem(maindir[i]));
                        }

    ...

    }

    //lbclasss.SelectedIndex 每次取值都为-1

            protected void btntypedel_Click(object sender, EventArgs e)
            {
                if (lbclasss.SelectedIndex > -1)
                {
                    lbclasss.Items.RemoveAt(lbclasss.SelectedIndex);
                }
            }

    解决方法:

            protected void Page_Load(object sender, System.EventArgs e)
            {         

                lbclasss.SelectedValue = Request["lbclasss"];

      ...

      }

  • 相关阅读:
    linux进程管理类
    linux关机重启指令
    linux分区及磁盘挂载
    linux的运行级别
    property
    访问限制机制
    类的组合与封装
    继承与派生
    logging模块
    re模块
  • 原文地址:https://www.cnblogs.com/lljinz/p/2151745.html
Copyright © 2011-2022 走看看