下拉框设定选择的值

if (下拉框.Items.FindByValue(设定的Value值) != null)
{
    下拉框.SelectedIndex = 下拉框.Items.IndexOf(下拉框.Items.FindByValue(设定的Value值));
}
if (下拉框.Items.FindByText(设定的Text值) != null)
{
    下拉框.SelectedIndex = 下拉框.Items.IndexOf(下拉框.Items.FindByText(设定的Text值));
}

 

转载于:https://www.cnblogs.com/2333hh/p/5235994.html

你可能感兴趣的:(下拉框设定选择的值)