开发者

Finding DropDownList index by text

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.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.


try tis.

ddlsample2.SelectedIndex = ddlsample.FindStringExact(ddlsample.Text);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜