Note that there are some explanatory texts on larger screens.

plurals
  1. POEval versus DataField in ASP:Datagrid
    primarykey
    data
    text
    <p>I have this really random problem with is bugging me. It works at the end of the day but the problem took some time to figure out and was wondering why this happens so if anyone shed some light on the subject I would be really grateful. Here is the problem</p> <p>I have the following two columns on my datagrid</p> <pre><code>&lt;asp:boundcolumn datafield="contentsection.Id" headerstyle-cssclass="dgHead" headertext="Section" itemstyle-cssclass="dgItem" /&gt; </code></pre> <p>and </p> <pre><code>&lt;asp:templatecolumn&gt; &lt;itemtemplate&gt;&lt;%#Eval("contentsection.Id") %&gt;&lt;/itemtemplate&gt; &lt;/asp:templatecolumn&gt; </code></pre> <p>The first column gives me the error of:</p> <p><strong>A field or property with the name 'contentsection.Id' was not found on the selected data source</strong></p> <p>but the second on runs fine. Any ideas or theories as to why this is happening ?</p> <p>The way that I call and bind my data is like so:</p> <p>Page Load Code Behind</p> <pre><code>ContentList.DataSource = ContentBlockManager.GetList(); ContentList.DataBind(); </code></pre> <p>The GetList() function it is overloaded and by default passed a 0</p> <pre><code>public static List&lt;ContentBlockMini&gt; GetList(int SectionId) { List&lt;ContentBlockMini&gt; myList = null; SqlParameter[] parameters = { new SqlParameter("@ContentSectionId", SectionId) }; using (DataTableReader DataReader = DataAccess.GetDataTableReader("dbo.contentblock_get", parameters)) { if (DataReader.HasRows) { myList = new List&lt;ContentBlockMini&gt;(); } while (DataReader.Read()) { myList.Add(FillMiniDataRecord(DataReader)); } } return myList; } </code></pre> <p>and my filling of the data record. The ContentSection is another Object Which is a property of the ContentBlock object</p> <pre><code>private static ContentBlockMini FillMiniDataRecord(IDataRecord DataRecord) { ContentBlockMini contentblock = new ContentBlockMini(); contentblock.Id = DataRecord.GetInt32(DataRecord.GetOrdinal("Id")); contentblock.Name = DataRecord.GetString(DataRecord.GetOrdinal("Name")); contentblock.SEOKeywords = DataRecord.IsDBNull(DataRecord.GetOrdinal("SEOKeywords")) ? string.Empty : DataRecord.GetString(DataRecord.GetOrdinal("SEOKeywords")); contentblock.SEODescription = DataRecord.IsDBNull(DataRecord.GetOrdinal("SEODescription")) ? string.Empty : DataRecord.GetString(DataRecord.GetOrdinal("SEODescription")); if (DataRecord.GetInt32(DataRecord.GetOrdinal("ContentSectionId")) &gt; 0) { ContentSection cs = new ContentSection(); cs.Id = DataRecord.GetInt32(DataRecord.GetOrdinal("ContentSectionId")); cs.Name = DataRecord.IsDBNull(DataRecord.GetOrdinal("ContentSectionName")) ? string.Empty : DataRecord.GetString(DataRecord.GetOrdinal("ContentSectionName")); contentblock.contentsection = cs; } return contentblock; } </code></pre> <p>There you go that is pretty much the start to end.</p>
    singulars
    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.
 

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