Usf Noor Usf Noor - 8 days ago 5
ASP.NET (C#) Question

Binding route name in repeater item template

Sorry for bad question statement..

<asp:Repeater ID="rp_Route" runat="server">
<ItemTemplate>
<li>
<asp:LinkButton ID="lb_Route" runat="server" PostBackUrl="<%$RouteUrl:routename=RouteHome%>">'<%# Eval("text") %>'</asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>


Repeater Binding

rp_Route.DataSource = _route.Get(route_id)
rp_Route.DataBind();


How can i bind route name, as in my code i have hard code RouteHome but i want to set route name according to my sql table.

Answer

You can use GetRouteUrl to retrieve URL by route name:

PostBackUrl='<%# GetRouteUrl( Eval("RouteName").ToString(), null )%>'

Note that we are passing null for parameters as you do appear to have any, and RouteName is just my guess at the column name that contains routes

Comments