开发者

selecting dropdownlist item in IronPython

I want to select a particular item in a dropdownlist by value, in asp.net using IronPython. I found I can do it li开发者_StackOverflowke 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜