开发者

get value based on index dropdown

开发者 https://www.devze.com 2023-04-04 10:28 出处:网络
I need to select a value from dropdown based on index. It is a super easy question. cannot fin开发者_开发问答d the property:

I need to select a value from dropdown based on index. It is a super easy question. cannot fin开发者_开发问答d the property:

I though doing something like:

dll.Items[index]

But still do not know how to get value for this index.


You can use dll.Items.FindByIndex(index); or dll.Items.FindByValue(val); according to your needs.


This loops through all items of an ASP combobox:

DataTable dt = (DataTable)comboBox1.DataSource;

for(int i = 0; i < dt.Rows.Count; ++i)
{
    string displayText = dt.Rows[i][comboBox1.DisplayMember].ToString();
    string valueItem = dt.Rows[i][comboBox1.ValueMember].ToString();
}


can be done like below

dll.Items[index].value

btw, FindByIndex, is like not available

0

精彩评论

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