SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Knowledge Base: Fail To Bind To ASP.NET DataGrid

rated by 0 users
This post has 0 Replies | 0 Followers

Top 10 Contributor
Posts 1,626
Firedancer Posted: 05-14-2005 1:05 PM

When binding an EntityList to an ASP.NET Datagrid with the option Create columns automatically at runtime enabled, you may encounter an error similar to the following.

Sample:

A field or property with the name 'Created Date' was not found on the selected datasource.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A field or property with the name 'Created Date' was not found on the selected datasource.

 

'Created Date' is actually the DisplayName supplied to the column via the DataField attribute (Your error may show different names depending on your columns). You will receive the above error when your DisplayName does not match your Column name. However, the DisplayName is used to give meainingful headers in datagrids which in most cases will be different from the column name.

The ASP.NET Datagrid somehow depends on the original column names and not the display name for data-binding. Therefore, to remedy this problem, you can:

Disable Create columns automatically at runtime and specify your own bound or template columns where you can manually set the field to bind to using the original column names.

- or -

Do not use DisplayName in your Entities if you need to enable Create columns automatically at runtime in the ASP.NET Datagrid.

 

Take note: This error does not occur in Winforms.

Software development made easy with Paladin RAD Framework. Save some trees, use Stickies.NET
Page 1 of 1 (1 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems