Tôi đang sử dụng:Cách tốt nhất để xem liệu RadioButtonList có giá trị được chọn không?
if (RadioButtonList_VolunteerType.SelectedItem != null)
hoặc làm thế nào về:
if (RadioButtonList_VolunteerType.Index >= 0)
hoặc làm thế nào về (mỗi câu trả lời Andrew Hare của):
if (RadioButtonList_VolunteerType.Index > -1)
Đối với những ai có thể đọc câu hỏi này, sau đây không phải là phương thức hợp lệ. Như Keltex đã chỉ ra, giá trị được chọn có thể là một chuỗi rỗng.
if (string.IsNullOrEmpty(RadioButtonList_VolunteerType.SelectedValue))
Nhân tiện, nó phải là "return list.SelectedItem! = Null". –
điểm tốt, tôi sẽ sửa lỗi. –