Retrieve Values from a ListBox

  • Thread starter Thread starter dudis3
  • Start date Start date
D

dudis3

Hello, I have this problem,
I have populated a multiselect ListBox, but now I need to retrieve
selected values, and use them as a parameters on the url e.g
http://www.aaa.com/Dynamicpage.aspx?states=(value or values) - which
will be selected from this ListBox, how do I separate multiple values
when they get selected?
Thank you
 
The ListBox class has a method (GetSelectedIndices) which returns an
array of integers which represent the index of items selected.

Info about that method here:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.listbox.getselectedindices.aspx

for example you can iterate through those items and get the values like
this:
string queryToAppend = null;
foreach( int i in listBoxName.GetSelectedIndices() )
{
string queryToAppend += listBoxName.Items.Value;
}


something of that nature.

-Patrick H
http://patpack.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top