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

问题描述

我正在尝试从列表框中删除和计时,但我收到此错误

I am trying to remove and time from a listbox but I am getting this error

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 





我试过



I have tried

enableEventValidation="false"

但页面无效它的方式。



ListBox将从Gridview中填充。但我认为每次点击页面上的按钮时,列表都会更新







感谢你的回复。



我尝试过的事情:



but the page is not working the way it should.

The ListBox is getting populated from a Gridview. But I think the list gets

updated everytime I click a button on the page.

thanks for you response.

What I have tried:

int a = LBDuties.SelectedIndex;
                LBDuties.Items.RemoveAt(a);
               // LBDuties.Items.Remove(LBDuties.SelectedValue);
              //  LBDuties.SelectedIndex = 1;

推荐答案


List<string> temp = new List<string>();

    foreach (string item in listBox1.Items)
    {
        string removelistitem = "RemoveValue";
        if(item.Contains(removelistitem))
        {
            ArraySample.Items.Add(item);
         }
     }

    foreach(string item in ArraySample)
    {
       listBox1.Items.Remove(item);
    }


这篇关于如何从列表框中删除项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:46
查看更多