//當DropDownList中有這個(gè)值時(shí),默認選中,否則選中第一個(gè)
private void setDropDownListValue(DropDownList drp, string value)
{
if (drp.Items.FindByValue(value) == null)
{
drp.SelectedIndex = 0;
}
else
{
drp.SelectedValue = value;
}
}
//根據text確定下拉框中的選中項
private void setDropDownListText(DropDownList drp, string text)
{
if (drp.Items.FindByText(text) == null)
{
drp.SelectedIndex = 0;
}
else
{
for (int i = 0; i < drp.Items.Count; i++)
{
if (drp.Items[i].Text == text)
{
drp.SelectedIndex = i;
break;
}
}
}
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。