The Hard Way
I work with people who like to type.
ddlSystemType.SelectedIndex = ddlSystemType.Items.IndexOf(ddlSystemType.Items.FindByValue(sdr[“systype_id”].ToString().Trim()));
ddlSystemType.SelectedValue = result.systype_id == null ? “-1” : result.systype_id;
But wait. I can beat that. I unaccountably only recently learned about the null coalescing operator. We could have used:
ddlSystemType.SelectedValue = result.systype_id ?? “-1”;
Briefly, if the value on the left is null, use the value on the right, if the value is not null, use the value.
PS. After you’ve been coding for hours and hours and switch to writing blog posts or emails in English do you end your sentences with semicolons instead of periods? I do. =oP