我有 asp.net 应用程序,其中有可编辑的网格视图,其中包含编辑、删除、添加选项。这个网格有像往常一样的模板字段。我还有一个具有静态字符串变量的静态类。我想将这些静态变量的值保留为模板字段的标题文本。所以我通过以下方式导入了我的常量类的命名空间:
<%@ Import Namespace="ConstantManagerNamespace" %>
然后我尝试了同一列:
1. <asp:TemplateField HeaderText=<%=ConstantManager.Name%>>
2. <asp:TemplateField HeaderText='<%=ConstantManager.Name%>'>
3. <asp:TemplateField HeaderText=<% ConstantManager.Name %>>
4. <asp:TemplateField HeaderText='<% ConstantManager.Name%>'>
all probable syntax to access my constant variable value but
我得到解析器错误:
Literal content ('<asp:TemplateField HeaderText=') is not allowed within a 'System.Web.UI.WebControls.DataControlFieldCollection'.
这个怎么做 ?