views:

13

answers:

0

Hi, I am trying to filter some data for a GridView Controls using a DropDownList Control. I am using EntityDataSource from EF 4 to query the Conceptual Model.

I am not able to visualize in GridView my data when selecting the DropDownList (Where Entity SQL), nothing happen in the page and only the DropDownList show /( the GridView(.

I do not receive and Expections.

Could you please guys tell me what I am doing wrong? Thanks for your support!

  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListPeoples.aspx.cs" Inherits="TestControls.ListPeoples" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:DropDownList ID="DropDownList1" runat="server" 
            DataSourceID="EntityDataSource1" DataTextField="LastName" 
            DataValueField="PersonID">
        </asp:DropDownList>
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
            ConnectionString="name=SchoolEntitiesConnectionString" 
            DefaultContainerName="SchoolEntitiesConnectionString" EnableFlattening="False" 
            EntitySetName="People">
        </asp:EntityDataSource>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="PersonID" DataSourceID="EntityDataSource2">
            <Columns>
                <asp:BoundField DataField="PersonID" HeaderText="PersonID" ReadOnly="True" 
                    SortExpression="PersonID" />
                <asp:BoundField DataField="LastName" HeaderText="LastName" 
                    SortExpression="LastName" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                    SortExpression="FirstName" />
                <asp:BoundField DataField="HireDate" HeaderText="HireDate" 
                    SortExpression="HireDate" />
                <asp:BoundField DataField="EnrollmentDate" HeaderText="EnrollmentDate" 
                    SortExpression="EnrollmentDate" />
            </Columns>
        </asp:GridView>
        <asp:EntityDataSource ID="EntityDataSource2" runat="server" 
            ConnectionString="name=SchoolEntitiesConnectionString" 
            DefaultContainerName="SchoolEntitiesConnectionString" EnableFlattening="False" 
            EntitySetName="People" Where="it.LastName = @lastName">
            <WhereParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="lastName" 
                    PropertyName="SelectedValue" Type="String" />
            </WhereParameters>
        </asp:EntityDataSource>
        <br />

    </div>
    </form>
</body>
</html>