使用 ASP Listview 的 Eval 作为内联 CSS 值

using Eval of ASP Listview as an inline CSS value

我的代码是:

<asp:ListView ID="lst1" runat="server">
  <ItemTemplate>
    <div style="width:<%#Eval("Rating")%>%">
    </div>
  </ItemTemplate>
</asp:ListView>

效果很好,但在 VisualStudio 编辑器中它被认为是无效的。 有什么办法让它生效吗?

我知道我可以在 Eval 中创建整个“style="width:xxx%"”,但我正在寻找另一种方式。

 <div style='<%# Eval("Rating", "width:{0}%") %>'></div>

它会让编辑接受它,但我不知道你还能做什么。