Sql – LinkDataSource can’t load DataContext

datacontextlinq-to-sqllinqdatasource

I am trying to populate a dropdown list control on an web page using VS 2008 and keep getting an error that it can't load the DataContext. My backend is a SQLx server 2005 DB. I create a Link To SQL data context and have 1 table in it. My LinKDataSource is as follows –
asp:LinqDataSource ID="LinqDataSource1" runat="server"ContextTypeName="DACDataContext" TableName="portfolio">
/asp:LinqDataSource

My dropdown definition is:
asp:DropDownList ID="ddlPortfolio" runat="server" Width="165px" DataSourceid="LinqDataSource1" DataTextField="porfolio_name"
DataValueField="portfolio_id">
/asp:DropDownList
I can see in my properties of my DatContext that the ContextTypeName is DACDataContext

The pecific errors I get are:
HttpException (0x80004005): Could not load type 'DACDataContext'.

and

InvalidOperationException: Could not find the type specified in the ContextTypeName property of LinqDataSource 'LinqDataSource1'.]

I know this must be something really stupid but I am at my wits end.

Please help.

Best Answer

Verify that DACDataContext is public and you may also try fully qualifying the type (ie. ContextTypeName="MyNamespace.DACDataContext")

Related Topic