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
精彩评论