I have an asp.net application, where I am creating editable grid view with editing, delete, add options, normal Template field in the form of this grid as I also have a static class that has static string variables. I want to keep the value of these fixed variables in the header text of the template field. That's why I have imported the name of my constant class by:
& lt;% @ import namespace = "constant manager namespace"%> Then I tried for the same column:
1 & lt; Asp: TemplateField HeaderText = & lt;% = Constant Messenger. Name% & gt; & Gt; 2. & lt; ASP: TemplateField HeaderText = '& lt;% = ConstantManager.name% & gt;' & Gt; 3. & lt; Asp: TemplateField HeaderText = & lt;% Constant_Manager.name% & gt; & Gt; 4. & lt; Asp: TemplateField HeaderText = '& lt;% Constant Messenger. Name% & gt;' & Gt; I found a parser error:
Little content ('& lt; asp: TemplateField HeaderText =' ) Is not allowed within a 'System.web.UI.WebControls.DataControlFieldCollection' How to do this?
The problem occurs because you want to embed the value in server-side control / other server-side control If you are trying to do this it is not possible directly in ASP.net, unless you use the database or custom expression builder.
For your precise position, you need to create a custom expression builder, which gives value to your stable class. / P>
The end result should look like this:
& asp: TemplateField HeaderText = "& lt; $ Constant Manager: Name & gt;" & Gt; which allows the aspx file to be fully supported, unless you have defined the custom expression builder with the "Constant Manager" prefix ". An example of creating a real custom expression builder can be found here. Besides,
Extra : Besides, I think the database will also work, but I do not think this is the exact solution to the situation.
Just use this syntax in aspx markup:
& asp: TemplateField HeaderText = "<# ConstantManager.Name>" gt; & gt; And, on page load, call:
Secure Zero Page_load (Object Sender, System.EventArgs e) {this.DataBind (); } Personally I do not like this solution because Page_Load part I hope it helps! However,
Comments
Post a Comment