开发者

DataContext not visible when choosing data source for LinqDataSource

开发者 https://www.devze.com 2022-12-25 03:42 出处:网络
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 th

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 do开发者_高级运维es appear. I do have several other working datacontexts - why is this one not being recognized by VS?


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


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.


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号