ASP.net 3.5 GridView Displaying DataTextField in ItemTemplate Column
Posted on 2010-08-16
I give up. I'm trying to create a GridView that displays a value in a related table in the Item Template field. Here's what I have.
I created a test WebSite with the following tables
Customer = CustomerID, CustomerName, CustomerTypeCode
CustomerType = CustomerTypeCode, CustomerType
I defined the relationship between the tables in SQL Server CustomerTypeCode = CustomerTypeCode
Then I created the test web site. I'm using Linq to Sql so I created a DBML file. Dragged the tables to the DBML. THe links appear as entered.
THen I added an asp web form and dragged a Gridview to the form. Next I set the Datasource as a Linq to SQL datasource based on the Customer table. I changed the CustomerTypeCode column to a Template Field
THen I went to the source code and changed the eval("CustomerTypeCode") to eval("CustomerType") in the Item Template.
When I display in Browser, I get the following message.
DataBinding: 'Customer' does not contain a property with the name 'CustomerType'.
What am I doing wrong?