<meta name='google-adsense-platform-account' content='ca-host-pub-1556223355139109'/> <meta name='google-adsense-platform-domain' content='blogspot.com'/> <!-- data-ad-client=ca-pub-6672515474304268 --> <!-- --><style type="text/css">@import url(https://www.blogger.com/static/v1/v-css/navbar/3334278262-classic.css); div.b-mobile {display:none;} </style> </head><body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar/4865038256408662682?origin\x3dhttp://imacomputernerd.blogspot.com', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
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: , ,

0 Comments:

Post a Comment

<< Home