Select One item in Model.StateList"> -6ren">
gpt4 book ai didi

spark-view-engine - Spark View Engine If 语句应用于属性

转载 作者:行者123 更新时间:2023-12-04 17:59:17 24 4
gpt4 key购买 nike

有没有更好、更干净的方法来设置 selected="true"?也许是嵌套的 if?

<select id="State" name="State" if="(Model.StateList.Count() > 0 )" >
<option value="">Select One</option>
<for each="KeyValuePair<string, string> item in Model.StateList">
<option value="${item.Value}" if="(Model.State == item.Value)" selected="true" >${item.Key}</option>
<option value="${item.Value}" if="(Model.State != item.Value)">${item.Key}</option>
</for>
</select>

最佳答案

<select id="State" name="State" if="Model.StateList.Any()" >
<option value="">Select One</option>
<option each="var item in Model.StateList" value="${item.Value}" selected="true?{Model.State == item.Value}" >${item.Key}</option>
</select>

关于spark-view-engine - Spark View Engine If 语句应用于属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1847843/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com