In this article I will explain with an example, how to resolve following error.
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ID'.
 
 
Error
The following error 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 specified with the databound control is not present in the data returned from database.
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'.
 
 
Solution
1. This happens generally due to misspelled column names, so please recheck your column name with the database table column name.
2. If the column names in the Control is correct then, check which columns your query is returning and the column that you have specified to the control is 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.