GLP
GLP

Reputation: 3675

How to use string.format with eval in the aspx page?

I have a repeater in my web page like following

<asp:Repeater runat="server" ID="AccountScrollRepeater" onitemdatabound="AccountRepeater_ItemDataBound">
<ItemTemplate>
    <tr class="primary-BL2" style="text-align:left">
        <td style="width:70px"><asp:Label runat="server" ID="AccountNoLabel" Text='<%# Eval("AccountNo") %>'></asp:Label></td>
        <td style="width:40px"><asp:HyperLink runat="server" ID="CustomerHyperLink" NavigateUrl="" Text='<%# Eval("CustId") %>' Enabled="false"></asp:HyperLink></td>
        ...
    </tr>
</ItemTemplate>

I would like to set the NavigateUrl of the CustomerHyperLink to following expression,

string.Format(AppSetting.Instance.GetSearchDetailUrl(SearchTypeEnum.Customer), '<%# Eval("CustNo") %>');

My question is instead of setting the NavigateUrl in the code behind, how do I put this in the aspx page?

Upvotes: 1

Views: 12943

Answers (1)

GeorgesD
GeorgesD

Reputation: 1082

Here we go

NavigateUrl ='<%# String.Format (AppSetting.Instance.GetSearchDetailUrl(SearchTypeEnum.Customer), Eval("intSMCID")) %>';

Upvotes: 7

Related Questions