delimited dropdownlist selectedvalue

R

rodchar

hey all,

given: dropdownlist selected value is a colon delimited value
2009A: Test1
2009: Test2
2008C: Test3
2008A: Test3.1

What's the easiest way to find Test3 in the items and set the selected index
to it?

thanks,
rodchar
 
S

Stanimir Stoyanov

Since your values are strings you, will have to go through all of them in a
loop, split each value into two and check the second part. Don't forget to
trim the value before comparing to the query (e.g. " Test3" does not equal
"Test3").

When you find a match, set the selected index to your current iterator value
and exit the loop to avoid redundant cycles.
 
R

rodchar

Thanks for the help,
rod.

Stanimir Stoyanov said:
Since your values are strings you, will have to go through all of them in a
loop, split each value into two and check the second part. Don't forget to
trim the value before comparing to the query (e.g. " Test3" does not equal
"Test3").

When you find a match, set the selected index to your current iterator value
and exit the loop to avoid redundant cycles.
 

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

Top