开发者

selecting dropdownlist item in IronPython

开发者 https://www.devze.com 2023-01-01 04:51 出处:网络
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

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

精彩评论

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