bind to property works, add something won't work

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
R

Ryan Liu

Hi,

In the data bind control, I try to bind same property twice to different
property,

<asp:GridView ID="gvTraffickingNetwork" runat="server"
AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink

NavigateUrl="Trafficking.aspx?networkId=<%#((TraffickingRequestSummary)Container.DataItem).Station.StationName%>"
Text="<%#
((TraffickingRequestSummary)Container.DataItem).Station.StationName%>"
runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>


The Text property will be set correctly, but NavigateUrl will not, the whole
thing <%# ... %> will just be treated as string.

Why something extra ("Trafficking.aspx?networkId=") make it won't work?

I can not use <asp:HyperLinkField> , which has DataNavigateUrlFormatString,
since I am trying to bind to property StationName of property Station.

Thanks,
Ryan


Thanks!
 
Hi,

In the data bind control, I try to bind same property twice to different
property,

<asp:GridView ID="gvTraffickingNetwork" runat="server"
AutoGenerateColumns="False" >
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:HyperLink

NavigateUrl="Trafficking.aspx?networkId=<%#((TraffickingRequestSummary)Cont ainer.DataItem).Station.StationName%>"
Text="<%#
((TraffickingRequestSummary)Container.DataItem).Station.StationName%>"
runat="server"></asp:HyperLink>
                                </ItemTemplate>
                            </asp:TemplateField>

The Text property will be set correctly, but NavigateUrl will not, the whole
thing <%# ... %> will just be treated as string.

Why something extra ("Trafficking.aspx?networkId=")  make it won't work?

I can not use <asp:HyperLinkField> , which has DataNavigateUrlFormatString,
since I am trying to bind to property StationName of property Station.

Thanks,
Ryan

Thanks!

Try to change it to

NavigateUrl='<%# "Trafficking.aspx?networkId=" +
((TraffickingRequestSummary)Cont ainer.DataItem).Station.StationName
%>'
 
Back
Top