Question

How to use Eval function in the query string in a databind control like list view .

 <asp:HyperLink ID="HyperLink12" runat="server" Target="_blank" NavigateUrl='<%# Eval('<%#Eval("bal")%>', "Rep_calc.aspx?year={0}") %>'> <%#Eval("bal")%></asp:HyperLink>

I want to eval the year with <%#Eval("bal")%> value .How to do this ?

Was it helpful?

Solution

Try using this

NavigateUrl='<%# "Rep_calc.aspx?year=" + Eval("bal")%>'

OTHER TIPS

Try this:

<asp:HyperLink ID="HyperLink12" runat="server" Target="_blank" NavigateUrl='<%# EvaluateYear(Eval("bal")) %>'><%#Eval("bal").toString() %></asp:HyperLink>

and then in your code behind:

public string EvaluateYear(object bal)
{
    return Eval(bal.ToString(), "Rep_calc.aspx?year={0}");
}

You may want to cast bal to it's datatype if you wish, but that might not make any difference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top