惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
V
V2EX
博客园 - 【当耐特】
Vercel News
Vercel News
雷峰网
雷峰网
爱范儿
爱范儿
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
NISL@THU
NISL@THU
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
P
Proofpoint News Feed
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
I
InfoQ
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 最新话题
Project Zero
Project Zero
Engineering at Meta
Engineering at Meta
V
Visual Studio Blog
AI
AI
Schneier on Security
Schneier on Security
B
Blog RSS Feed
T
Tor Project blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Cyber Attacks, Cyber Crime and Cyber Security
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
Arctic Wolf
Webroot Blog
Webroot Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main

博客园 - InFuture

变成百万富翁的二十五种方法 今天终于测试解决了WCF传递大数据量的问题 关于工作流设计方面的一些经验总结 Telnet客户端 字符串表达式求值(转) silverlight DataGrid模板列的动态生成 关于事件处理的完整框架Event,delegate,event args,无图有真相。 关于树形结构父类查子类,子类查父类的方法 最近准备整理一下手头资料,开发一个工作流和表单管理系统 今天装好了window 7 Silverlight 客户端如何访问WCF 如何让用户控件占满全部页面,silverlight用户控件开发问题 wpf 数据绑定有关讲解 ASP.NET 3.5 Extensions: Dynamic Data Web Site 要點整理(转载) 免费的微软OneCare防病毒软件 Visual Studio 2008 SP1: EntityDataSource Where Clause(转载) 今天装了VS2008 Sp1!真是非常激动!(VS2008 sp1下载地址) ASP.NET里的支架:Dynamic Data Support(转载) VS2008的黑色皮肤
Visual Studio 2008 SP1: EntityDataSource for ASP.Net (转载)
InFuture · 2008-08-22 · via 博客园 - InFuture

Visual Studio 2008 SP1: EntityDataSource for ASP.Net

EntityDataSource is a new DataSource control for ASP.Net (just like ObjectDataSource and SQLDataSource and more recent - LinqDataSource) which makes declaratively binding ASP.NET UI controls to Entity Data Models very easy.

In this post I will build a simple web application that uses EntityDataSource in order to demo how it is being used.

1. Create a simple Web Application, and create an initial GridView on it.

<body>

    <form id="form1" runat="server">

    <h1>

        Using the EntityDataSource</h1>

    <asp:GridView runat="server" ID="GridView" />

    </form>

</body>

2. Create a new ADO.Net Entity Data Model. Add a new ADO.Net Entity Data Model item to the project, and generate a model from an existing database. For this sample I am using the Bank DB Schema, but you can use any other schema as well.

Visual Studio 2008 SP1 Beta EntityDataSource

3. If the EntityDataSource is not shown in the Toolbox under the Data category - Add it. Right click the toolbox and select the Choose Items... option.

Visual Studio 2008 SP1 Beta EntityDataSource

In the Choose Toolbox Item dialog, set the filter to Entity and check the EntityDataSource component.

4. Add a reference to System.Web.Entity.dll. The EntityDataSource component is part of a new assembly in SP1 called System.Web.Entity.dll, and its designer support components can be found in System.Web.Entity.Design.dll.

5. Bind the grid to the EntityDataSource. Switch to design view and select the gridview to display the smart tag. In the Choose Data Source drop down select the option <new data source...>

Visual Studio 2008 SP1 Beta Entity DataSource

This will start the Data Source Configuration Wizard. Select the Entity Data Source and provide a meaningful name.

Visual Studio 2008 SP1 Beta EntityDataSource

Select the name of the connection to use and the name of the container.

Visual Studio 2008 SP1 Beta EntityDataSource

Select the name of the EntitySet you want to display its entities and the columns you would like to display. If the EntitySet contains a hierarchy of entity types, you can filter the type you want.

Visual Studio 2008 SP1 Beta EntityDataSource

When we click the "Finish" button, VS 2008 will declare a <asp:EntityDataSource> within the .aspx page, and update the <asp:gridview> to point to it.

Visual Studio 2008 SP1 Beta EntityDataSource

And in the source view it looks like:

<asp:GridView runat="server" ID="GridView" " DataKeyNames="CustomerID"

    DataSourceID="EntityDataSource" >

    <Columns>

        ...

    </Columns>

</asp:GridView>

<asp:EntityDataSource ID="EntityDataSource" runat="server"

    ConnectionString="name=BankEntities" ContextTypeName=""

    DefaultContainerName="BankEntities" EntitySetName="Customers">

</asp:EntityDataSource>

6. If we now run this application, we can see the details in the grid.

Visual Studio 2008 SP1 Beta EntityDataSource

In this post I had a step by step guide on how to use the EntityDataSource in a very basic way. In the next post I'll show how to filter entities using a where clause.

Enjoy!