quinnipiac0807
Programmer
I have this line of code that works with my class. I want this to return null if selecteditem.value == 0. Problem being that when null is converted to int it returns 0. I need to put a null value into my database. Any suggestions.
address.StateID = Convert.ToInt32((ddlState.SelectedItem.Value.ToString().Length==0)?null:ddlState.SelectedItem.Value.ToString().Trim());
address.StateID = Convert.ToInt32((ddlState.SelectedItem.Value.ToString().Length==0)?null:ddlState.SelectedItem.Value.ToString().Trim());