Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change this</p> <p><strong>aspx file</strong></p> <pre><code>&lt;asp:GridView ID="DataViewer" runat="server"&gt; &lt;Columns&gt; &lt;TemplateColumn&gt; &lt;ItemTemplate&gt; &lt;div style='width: &lt;%# Eval("OrderCount") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/TemplateColumn&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>to this</p> <p><strong>aspx file</strong></p> <pre><code>&lt;asp:GridView ID="DataViewer" runat="server"&gt; &lt;Columns&gt; &lt;ItemTemplate&gt; &lt;div style='width: &lt;%# Eval("OrderCount") %&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>Explanation: The error message does in fact tell you what's wrong, although it's cryptic if you don't know what it means! Here's a breakdown:</p> <blockquote> <p>Parser Error Description: An error occurred during the parsing of a resource required to service this request. </p> </blockquote> <p>This means that something went wrong while the <strong>ASP.NET</strong> engine was examining a source file. The hints are 'request' (as in, a web request was made) and 'during the parsing of a resource'.</p> <blockquote> <p>Please review the following specific parse error details and modify your source file appropriately.</p> </blockquote> <p>The error is in a file parsed by asp.net, not the C# compiler. This means the problem is in the <code>aspx</code>, not a <code>.cs</code> file.</p> <blockquote> <p>Parser Error Message: System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'TemplateColumn' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl</p> </blockquote> <p>Here, <em>something</em> is expecting to contain things which are <code>DataControlField</code>s, but you've given it a <code>TemplateColumn</code>, which is a <code>HtmlGenericControl</code> (which isn't a <code>DataControlField</code>, so isn't what it wants). So we examine the aspx markup and say, where is there a <code>TemplateControl</code>? And we see that your <code>GridView\Columns</code> collection has a <code>TemplateControl</code>. Whereas (on checking the help) it should be <em>directly</em> containing an <code>ItemTemplate</code>, when you want a templated column. And we're done.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload