Usf Noor Usf Noor - 1 year ago 54
ASP.NET (C#) Question

Binding route name in repeater item template

Sorry for bad question statement..

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

Repeater Binding

rp_Route.DataSource = _route.Get(route_id)

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 Source

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