[英]aspx bind data with '#' symbol to gridview
Been trying to fix this for hours and I know that the problem is with the '#' but I could not find any solution to this problem. 尝试修复此问题已有几个小时,我知道问题出在'#'上,但是我找不到解决此问题的任何方法。 My field name in the database is 'HRTRN#'.
我在数据库中的字段名称是“ HRTRN#”。
<asp:TemplateField HeaderText="Transaction#">
<EditItemTemplate>
<asp:TextBox ID="TextBox13" runat="server" Text='<%# Bind("HRTRN#") %>' Width="50px" Height="17px" MaxLength="14"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("HRTRN#") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Does anyone know the solution for this to make the field name containing # symbol accessible? 有谁知道解决方案,使包含#符号的字段名称可访问?
You should change your code from : 您应该从以下位置更改代码:
Bind("HRTRN#")
To 至
Bind("[HRTRN#]")
Since it contains special charcters. 由于它包含特殊字符。 ( you would do that also for columns with spaces).
(您也可以对带有空格的列执行此操作)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.