Radim Motycka

Radim Motycka

  • NA
  • 31
  • 32k

EntityDataSource vs Routing

Jan 22 2012 4:39 PM
Hello,
Pls would you advise?

I am using routing from hyperlink button. It creates the route for instance "http://localhost:52565/home/1" .

And then I am passing it into entitydatasource.


<asp:EntityDataSource ID="WitzenDataSource" runat="server"
        ConnectionString="name=WitzenDBEntities"
        DefaultContainerName="WitzenDBEntities" EnableFlattening="False"
        EntitySetName="Witzens" Where="it.TagID == @TagID and it.Approved == true"
         >
        <WhereParameters>
            <asp:RouteParameter Name="TagID" RouteKey="home" DbType="Int16"   />
        </WhereParameters>
    </asp:EntityDataSource>

and the output to the ListView shows nothing.
If I change it into:

<asp:EntityDataSource ID="WitzenDataSource" runat="server"
        ConnectionString="name=WitzenDBEntities"
        DefaultContainerName="WitzenDBEntities" EnableFlattening="False"
        EntitySetName="Witzens" Where="it.TagID == 1 and it.Approved == true"
         >
       <%-- <WhereParameters>
            <asp:RouteParameter Name="TagID" RouteKey="home" DbType="Int16" />
        </WhereParameters>--%>
    </asp:EntityDataSource>

It works normally and I get the needed filtered output.
Please advice am I missing something?

I also added    DataKeyNames="ID" or  DataKeyNames="TagID"   into ListView.
Route def is:

RouteTable.Routes.MapPageRoute("HomePageFiltered", "home/{TagID}", "~/Pages/HomePage.aspx");

And hyperlink button is:

 <asp:HyperLink  runat="server" Text='<%# Eval("Tag") + Eval ("Witzen.Count","({0})") %>' NavigateUrl='<%# GetRouteUrl("HomePageFiltered", new { TagID = Eval("TagID") } ) %>'  />

Many Thx

Radim


Answers (1)