Exception - DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'x'
 
Author:
Filed Under: ASP.Net  |  C#.Net  |  VB.Net  |  Issues and Exceptions
Published Date: Aug 07, 2011
Views: 4467
 

Abstract: Here Mudassar Ahmed Khan has explained the exception DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID' in ASP.Net

Comments:  1

 

Server Error in '/ASP.Net' Application.

 

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID'.

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: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID'.

 

Cause

The above exception occurs when a specified data item in the web control does not exist in the schema of the returned DataRowView. In other words the column that you have specified with the databound control is not present in the data returned from database

 

Solution

1. Generally occurs due to misspelled column names, hence one should recheck that.

2. If the column names in the Control is correct the check what columns your query is returning and the column that you have specified to the control exists or not.

3. Many times due to exceptions nothing is returned in that case check the code for such issues.

 

Examples

1. If one specifies DataKeyNames property as ID and the actual column name is CustomerID. It will throw the above error.

2. If one specifies DataTextField or DataValueField property as ID and the actual column name is CustomerID. It will throw the above error.

 

Overall it is a minor issue and can be easily solved using the above steps









Related Articles



Comments



Add comments

You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment

Please note that all comments are moderated and will be deleted if they are
  • Not relavant to the article
  • Spam
  • Advertising campaigns or links to other sites
  • Abusive content.
Please do not post code, scripts or snippets.

Name*: Required
Email*: Required
Comment*: Required
Security code*: CaptchaInvalid Security Code
  Submit