SelectedValue vs SelectedItem.Value of DropDownList

后端 未结 5 1765
猫巷女王i
猫巷女王i 2020-12-08 09:37

I\'m working on an old project written and then patched by several people over the years. At some places they have used SelectedValue property and other places they used Sel

5条回答
  •  天命终不由人
    2020-12-08 10:19

    They are both different. SelectedValue property gives you the actual value of the item in selection whereas SelectedItem.Text gives you the display text. For example: you drop down may have an itme like

    
    

    So, in this case SelectedValue would be de and SelectedItem.Text would give 'German'

    EDIT:

    In that case, they aare both same ... Cause SelectedValue will give you the value stored for current selected item in your dropdown and SelectedItem.Value will be Value of the currently selected item.

    So they both would give you the same result.

提交回复
热议问题