通过查找文本的DropDownList指数 [英] Finding DropDownList index by text

查看:119
本文介绍了通过查找文本的DropDownList指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个填充的DropDownList。我要如何找到它的文本值是X?

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.

这篇关于通过查找文本的DropDownList指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆