문제

I am trying to set a combobox.selectedValue to a string which works but when its nullorempty it errors out. I have tried the following code to no avail:

        if (string.IsNullOrEmpty(docRelComboBox.SelectedValue.ToString()))
        {
            document = "other";
        }

        else
        {
            document = docRelComboBox.SelectedValue.ToString();
        }

The combobox is databound but in theory it could be nullorempty in certain situations and I need to be able to pass the other value at those times. Any help would be great.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top