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