Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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"
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;
Posted
Updated 6-Jul-17 1:20am
v2
Comments
j snooze 5-Jul-17 17:41pm    
Are you checking for if(!Page.IsPostback) ?? If you are filling the drop down everytime the page posts back you may get this. If you have the listbox filling in only on initial page entry you should be ok. Check that out.

More details would help to understand the problem better. From your explanation it is not clear when and where (code part) the exception is occurring. If you want to prevent postback for a specific control, where postback is not necessary, set AutoPostBack property to 'false'.
 
Share this answer
 
Comments
Member 9331278 7-Jul-17 11:40am    
I realized that is does not have to do with removing items in the list box
but when the gets postback
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);
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900