I want to select a particular item in a dropdownlist by value, in asp.net using IronPython. I found I can do it like this
listItem = ddl.Items.FindByValue(x)
if listItem != None: listItem.Selected = True
But I want to do it in one line
I want to select a particular item in a dropdownlist by value, in asp.net using IronPython. I found I can do it like this
listItem = ddl.Items.FindByValue(x)
if listItem != None: listItem.Selected = True
But I want to do it in one line
This is one solution I can think of that might work:
if ddl.Items.FindByValue(x): ddl.Items.FindByValue(x).Selected = True
It is kinda redundant, but if you really want a one-liner I guess it will do.
There probably is a better solution.