-1

In C#, I created a string test = "test2"; and I wanted to get the index of the test2 from my asp:dropdownlist.

these are the items in my drop down list

                test1
                test2
                test3
19GreenBlankets
  • 95
  • 1
  • 12

1 Answers1

3

I'm not sure if you are lazy or not but hey maybe this is what you looking for:

        string test = "test2";
        int ps = yourdrplst.Items.IndexOf(yourdrplst.Items.FindByText(test));
Martius Umali
  • 122
  • 1
  • 2
  • 14
  • I'm 11 years old. It's hard to take it all in. Understanding this and that. Thank you. The ps has the value. – 19GreenBlankets Dec 20 '17 at 23:18
  • That's true. I don't know the reason why you are interested on programming but hang in there little one. – Martius Umali Dec 20 '17 at 23:23
  • 1
    @19GreenBlankets you are way ahead of most 11 year olds. Hang in there and keep on learning. Don't let the haters distract you. Thank you Martius Umali for taking the time to answer. – BasicIsaac Dec 21 '17 at 00:05