I have a populated DropDownList. How do I find the index whose Text value is "x"?
If you want to get value on server side you can follow this. ddlsample. SelectedIndex = ddlsample. Items.
The following terms are important to understand as you read this article: A standard list box is a box containing a list of multiple items, with multiple items visible. A drop-down list is a list in which the selected item is always visible, and the others are visible on demand by clicking a drop-down button.
If you want to get value on server side you can follow this.
ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByValue("x")); // If you want to find text by value field.
ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByText("x"));// If you want to find text by TextField.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With