c# - 在 C# 中绑定 2 个字段
问题描述
我正在尝试在 aspx 页面中绑定 2 个字段
使用这个脚本
<asp:Label runat="server" ID="lblListText" Text=<%# Eval("CodeType") %> : <%# Eval("Code") %> > </asp:Label>
但是你我收到了这个错误
Compiler Error Message: CS1525: Invalid expression term '>'
我试过
<asp:Label runat="server" ID="lblListText" Text=<%# Eval("CodeType") : # Eval("Code") %> > </asp:Label>
收到
Compiler Error Message: CS1040: Preprocessor directives must appear as the first non-whitespace character on a line
试过了
<asp:Label runat="server" ID="lblListText" Text=<%# Eval("CodeType") : Eval("Code") %> > </asp:Label>
拿到
Compiler Error Message: CS1003: Syntax error, ',' expected
不知道如何获得 CodeType 然后是冒号然后是 Code?
解决方案
我找到了答案
<asp:Label runat="server" ID="lblListText" Text='<%#Eval("CodeType").ToString() +" : "+ Eval("Code").ToString() %>' > </asp:Label>
推荐阅读
- javascript - 无法在 Django 中显示表单
- c++ - 仅具有静态方法的模板类使用 .cpp 文件实现给出错误
- javascript - 是否可以使用 Highcharts 在区域图上设置 upColor?
- amazon-web-services - 如何将 mysql 数据库集成到 AWS AMPLIFY REST API
- php - 根据传递第一个数组中的一个值的另一个数组在数组中搜索值
- asp.net - 如何根据下拉列表值启用/禁用文本框
- visual-studio - 奇怪的 Clickonce 签名行为
- react-redux - 使用 next.js 进行 SSR 时如何处理身份验证令牌?
- python - 如何从 peewee 数据库中获取行数?
- go - 如何接收要插入的 json