bind to property works, add something won't work

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!
 
G

Guest

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
%>'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top