SelectedItem.Value vs SelectedValue

เคยสงสัยมั้ยว่า SelectedItem.Value กับ SelectedValue ต่างกันอย่างไร
ทั้งสองคำสั่ง ล้วนเป็นคำสั่งที่ใช้ในการดึงค่าออกมาจาก control ใน .net framework เช่น dropdownlist, radiobuttonlist เป็นต้น แต่
- SelectedValue จะ return เป็นค่าของ SelectedItem ดังนั้นถ้าไม่มีค่าก็จะแสดงเป็นค่า “”
- SelectedItem.Value จะ return เป็นค่าของ item ที่ถูก select ดังนั้นถ้าไม่มี item ที่ถูก select จะ error
Categories Category: ASP.net+VB, Computer Tags Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>