评估带括号的列名称
Eval column name with bracket
我正在尝试将 column
绑定到 datalist
,而 column name
是 Standard Size Supported (bytes)
。
datalist
有一个 table
,我为 column
做了如下操作:
<tr>
<td colspan="1">Standard Size Supported (bytes)</td>
<td colspan="3">
<asp:Label ID="lblStandard" runat="server" Text='<%# Eval("Standard size supported (bytes)")%>' class="form-control"></asp:Label>
</td>
</tr>
执行代码后,提示错误列不存在。我知道这是由于 column
名称中的括号所致。我试过 <%# ((DataRowView)Container.DataItem)["Standard size supported (bytes)"] %>
和 <%# DataBinder.GetPropertyValue(Container.DataItem, "Standard size supported (bytes)") %>
。但它不起作用,知道吗?它来自现有系统,假设我无法重命名 column
.
@Rahul Singh 提出的另一种解决方法。
在 select 查询中,我已将其更改为
"SELECT `Standard size supported (bytes)` as 'Standard' FROM `tableA`
并且在 aspx 文件中,我已将 Eval
更改为
<tr>
<td colspan="1">Standard Size Supported (bytes)</td>
<td colspan="3">
<asp:Label ID="lblStandardMTU" runat="server" Text='<%# Eval("Standard") %>' class="form-control"></asp:Label>
</td>
</tr>
我正在尝试将 column
绑定到 datalist
,而 column name
是 Standard Size Supported (bytes)
。
datalist
有一个 table
,我为 column
做了如下操作:
<tr>
<td colspan="1">Standard Size Supported (bytes)</td>
<td colspan="3">
<asp:Label ID="lblStandard" runat="server" Text='<%# Eval("Standard size supported (bytes)")%>' class="form-control"></asp:Label>
</td>
</tr>
执行代码后,提示错误列不存在。我知道这是由于 column
名称中的括号所致。我试过 <%# ((DataRowView)Container.DataItem)["Standard size supported (bytes)"] %>
和 <%# DataBinder.GetPropertyValue(Container.DataItem, "Standard size supported (bytes)") %>
。但它不起作用,知道吗?它来自现有系统,假设我无法重命名 column
.
@Rahul Singh 提出的另一种解决方法。 在 select 查询中,我已将其更改为
"SELECT `Standard size supported (bytes)` as 'Standard' FROM `tableA`
并且在 aspx 文件中,我已将 Eval
更改为
<tr>
<td colspan="1">Standard Size Supported (bytes)</td>
<td colspan="3">
<asp:Label ID="lblStandardMTU" runat="server" Text='<%# Eval("Standard") %>' class="form-control"></asp:Label>
</td>
</tr>