Datagrid

admin

Administrator
Staff member
Hi everyone, I have encountered another problem on the coding.
I am using a data grid and I have written code in the Edit template, column, label properties, databindings under Custom binding expression:
DataBinder.Eval(Container, "DataItem.UserID")
in order to call the data out from the database and display the result in the data grid. UserID is a primary key in the database will this be the cause of this error message.

Server Error in '/ATS1' Application.
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name UserID.
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: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name UserID.

Can anyone show me an example on the coding?

Thank you for your help.Using the primary key is absolutely fine, it looks like the UserID field doesn't exist in your datasource or you are binding to the wrong datasource. In any event, it cannot locate the UserID property.

Perhaps it needs to be like this?:

DataBinder.Eval(Container.DataItem, "UserID")Its okay to use this expression
<%# DataBinder.Eval(Container, "DataItem.UserID") %>
Make suer your tag look like this, also make sure that the UserID is included in your "Select Statement"Thank cipher for your help :)
 
Back
Top