0

I have a ASP.net webforms application. When I load a page I bind the DropDownLists this way:

ListItem cItem = DropDownList1.Items.FindByText("foo");
if(cItem!=null)
{
    cItem.Selected = true;
}

Question: Is there a way to do it with the conditional operator?

DropDownList1.Items.FindByText("foo")?.Selected = true; //odes not work
Toshi
  • 2,532
  • 4
  • 17
  • 45

0 Answers0