I need to select an item from drop down list using its text. The problem is when I use below code, it selects the exact name only. What I want is:
Name
--------
abc
def
xyz
This is what I tried to do.
ddlSup.SelectedIndex = ddlSup.Items.IndexOf(ddlSup.Items.FindByText("a"))
When I write 'a' I want to get abc, in my case am getting nothing. Thanks.
try this:
you can modify this code, instead of using
Contains
function you can also useStartsWith
or some string manipulation function available.