您的位置首页百科问答

DropDownList的两个属性的区别。

DropDownList的两个属性的区别。

的有关信息介绍如下:

DropDownList的两个属性的区别。

public virtual ListItem SelectedItem { get { int selectedIndex = this.SelectedIndex; if (selectedIndex >= 0) { return this.Items[selectedIndex]; } return null; }}public virtual string SelectedValue { get { int selectedIndex = this.SelectedIndex; if (selectedIndex >= 0) { return this.Items[selectedIndex].Value; } return string.Empty; }}在没有选定任何项的情况下,SelectedValue默认值是string.Empty,而SelectedItem默认值是null(通过SelectedItem.Value可能发生异常)