delimited dropdownlist selectedvalue

  • Thread starter Thread starter rodchar
  • Start date Start date
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
 
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.
 
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.
 
Back
Top