Tutorial :DataContext not visible when choosing data source for LinqDataSource



Question:

I have a page on which I've thrown a LinqDataSource and a GridView. I've created a DataContext LINQ-to-SQL class called dcResidents.dbml. When I attempt to configure the LinqDataSource to utilize the dcResidents data context - it doesn't appear in the list of options...though under class view (tab in VS) it does appear. I do have several other working datacontexts - why is this one not being recognized by VS?


Solution:1

Try to Build your project first ( Debug-menu > Bulid Projectname ) before you configure the DataSource-controls source.


Solution:2

Okay, here is my work-around:

  1. Remove data connections and re-add for SQL servers.
  2. Reference DataContext in code-behind first, then try using drag-and-drop interface.


Solution:3

I had the same issue; however, I solved it by verifying if the System.Data.Linq is referenced in web.config or not.

Strangely, it exsited under References of the project and compiler could compile the application successfully. However, when I wanted to view the application in browser, I received runtime error, which stated it cannot find the related assembly. So, I added that manually to the web.config:

<system.web>    <compilation debug="true" targetFramework="4.5">      <assemblies>        <add assembly="System.Data.Linq, Version=4.0.30319.17929, Culture=neutral, PublicKeyToken=b77a5c561934e089" />      </assemblies>    </compilation>    <httpRuntime targetFramework="4.5" />  </system.web>   

I hope it solves your issue.

Cheers.


Solution:4

I created a new local installation of my website and then opened in VS 2010, and this time it saw the Data Context. it means u first must be debug your project then saw the Data Context.


Solution:5

I think this will help for other peoples and save its time. In VS2017:
1. configure .dbml file,
2. save project changes, close and re-open IDE with your project.
3. try to continue configuration using your datacontext


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »