Donate

A field or property with the name 'ClassName.Property' was not found on the selected data source In ASP.NET Gridview

As i was running an asp.net application in my local machine, I encountered an exception which is the title of this post. This asp.net app runs perfectly from the other workstation. I tried searching solutions in google but found out that most of the recommendations were to redo the model or the business tier.

One option I tried was to replace the BoundField of the gridview with TemplateField with label as the bound control using Eval("expression"). Glad that worked. It could be an IIS issue as stated in other forums. Here's the gridview markup changes:
(Windows 7 64 Bit using BoundField)
 <asp:BoundField DataField="Product.Name" HeaderText="Name" >  
      <ItemStyle Width="350px" />  
 </asp:BoundField>  
(Windows 7 32 Bit using TemplateField)
<asp:TemplateField HeaderText="Product Name">  
     <ItemStyle Width="350px"/>  
     <ItemTemplate>  
     <asp:Label ID="lblProductName" Text='<%# Eval("Product.Name")%>' runat="server">     
     </asp:Label>  
     </ItemTemplate>                
  </asp:TemplateField>  
Note: I also tested the program in a Windows 8 64 Bit machine. TemplateField simply works. I believe that BoundField has some issues with 32 bit machines.
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.