如何删除asp.net列表框中的选定值 [英] how to deleted selected values in listbox in asp.net

查看:79
本文介绍了如何删除asp.net列表框中的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除asp.net中列表框中的选定值

how to deleted selected values in listbox in asp.net

推荐答案

尝试以下操作:
Try this:
public static void RemoveSelected(this ListControl source)
{
    foreach (var item in source.Items.Cast<ListItem>().Where(li => li.Selected).ToList())
        source.Items.Remove(item);
}

protected void btnRemove_Click(object sender, EventArgs e)
{
    lstCity.RemoveSelected();
}



此处获取更多类似的线程 [ ^ ]

您也可以使用JavaScript,在此处查看 [



Get more similar threads here[^]

You can make it using JavaScript also, See here[^]


List<listitem> itemsToRemove = new List<listitem>();

        foreach (ListItem listItem in ListBox1.Items)
        {
            if (listItem.Selected)
                itemsToRemove.Add(listItem);
        }

        foreach (ListItem listItem in itemsToRemove)
        {
            ListBox1.Items.Remove(listItem);
        }


服务器端:从Asp.net列表框中删除选定的项目 [ ^ ]
Server side: Remove selected Items from Asp.net ListBox[^]
List<listitem> itemsToRemove = new List<listitem>();

        foreach (ListItem listItem in ListBox1.Items)
        {
            if (listItem.Selected)
                itemsToRemove.Add(listItem);
        }

        foreach (ListItem listItem in itemsToRemove)
        {
            ListBox1.Items.Remove(listItem);
        }</listitem></listitem>



客户端:使用以下方法将Listbox项移动到另一个Listbox并将其删除jQuery [ ^ ]



Client Side: Move and remove Listbox item to another listbox using jQuery[^]


这篇关于如何删除asp.net列表框中的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆