Q: select value in dropdown list

G

Guest

Hello,
I usee this to find string sD in drop down list and select the value.
dllSP.SelectedIndex = dllSP.Items.IndexOf(dllSP.Items.FindByText(sD);
Can I get FindByText work with wildcards? So dropdown list has xyzt, and if
sD is xyz, I need to select xyzt. Right now it does not select since is
expects whole match. How can I do this?
Thanks,
Jim.
 
W

William F. Robertson, Jr.

You will need to manually loop the items collection looking for the item you
seek. This is nearly exactly what the FindByText does.

for( int i = 0 ; i < dllSP.Items.Count ; i++ ) {
if ( ddlSP.Items.Text.StartsWith( "xyz" ) ) {
dllSP.SelectedIndex = i;
break;
}
}

bill
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top