0
comments
|
Thursday, November 1, 2007
How to easily remove multiple list items with ASP.NET C#
I searched everywhere for code to do this and found about 10-12 posts of example that includes dozens of lines of code and still didn’t even work correctly, then I found this one and thought I would share, it is an easy small piece of code that removes multiple selected items from a listbox in C#.
int i = ListBox1.Items.Count;
for(int j = 0; j < i; j++)
{
ListBox1.Items.Remove(ListBox1.SelectedItem);
}
This would be called on button click (as an example). Works great for me. Hope it helps.
Labels: ASP.NET, C#, removing multiple selcted list items


0 Comments:
Post a Comment
<< Home