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

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
博客园_首页
J
Java Code Geeks
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
Schneier on Security
Schneier on Security
Hugging Face - Blog
Hugging Face - Blog
PCI Perspectives
PCI Perspectives
O
OpenAI News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hacker News: Ask HN
Hacker News: Ask HN
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Heimdal Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 聂微东
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
美团技术团队
V
V2EX
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cybersecurity and Infrastructure Security Agency CISA
有赞技术团队
有赞技术团队
腾讯CDC
Cloudbric
Cloudbric
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
SecWiki News
SecWiki News
IT之家
IT之家
C
Cisco Blogs
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
S
Schneier on Security
Security Latest
Security Latest
Scott Helme
Scott Helme
H
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 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 for ASP.Net (转载) 今天装了VS2008 Sp1!真是非常激动!(VS2008 sp1下载地址) ASP.NET里的支架:Dynamic Data Support(转载) VS2008的黑色皮肤
Visual Studio 2008 SP1: EntityDataSource Where Clause(转载)
InFuture · 2008-08-22 · via 博客园 - InFuture

Visual Studio 2008 SP1: EntityDataSource Where Clause

This post in one of a series of blog posts about SP1 of Visual Studio 2008 and .Net Framework 3.5.

In the previous post about the EntityDataSource I've showed how to use it in a very basic way, which meant that I didn't customize the EntityDataSource at all. In this post I'll show how to filter the displayed entities by adding a where clause expressed by an Entity SQL statement.

EntityDataSource Where

Taking from where I finished in the last post, I now want to filter the customers by their city, according to the city that was selected in a listbox control. To so that:

1. Add a listbox control that contains items for filtering the list of entities. For example, if we want to filter customers by city, we will add a listbox similar to:

<asp:ListBox ID="list" runat="server" AutoPostBack="true">

    <asp:ListItem Text="Tel Aviv" Value="Tel Aviv" />

    <asp:ListItem Text="Haifa" Value="Haifa" />

</asp:ListBox>

2. Go to the property grid of the EntityDataSource and locate the Where property. In this property, write an Entity SQL statement that may have parameters that start with @, or use the Expression Editor to do this. For example: it.City == @city

EntityDataSource Where Bug Expression Editor

3. Using the Add Parameter button in the Expression Editor, add a new parameter with the same name as you used in the where clause, and choose the parameter source. You can choose to take the parameter value from a session value, from another control's value, and some other options. For this sample, choose Parameter Source = Control, and from the ControlID dropdown, select the listbox control ID.

EntityDataSource Where Parameter Source

Note: In the Beta of SP1 of Visual Studio 2008 and .Net Framework 3.5 there is a known bug that prevents you from using this Expression Editor and choose the parameter source, which will be fixed when we RTM. For now, after specifying the Where Expression, switch to the source view and add the parameters manually:

<asp:EntityDataSource ID="EntityDataSource" runat="server" ConnectionString="name=BankEntities"

  ContextTypeName="" DefaultContainerName="BankEntities" EnableDelete="True" EnableInsert="True"

  EnableUpdate="True" EntitySetName="Customers" Where="it.City == @city">

  <WhereParameters>

    <asp:ControlParameter Name="city" Type="String" ControlID="list" PropertyName="SelectedValue" />

  </WhereParameters>

</asp:EntityDataSource>

4. Run and browse to the page, and select one of the values in the listbox. The data shown in the gridview will be refreshed according to the where clause and the selected value of the listbox.

EntityDataSource Where ControlParameter

Enjoy!