Reputation: 3391
I have a gridview with a template field that has a HyperLink:
<asp:TemplateField ItemStyle-Width="12%" HeaderText="VER" HeaderStyle-HorizontalAlign="Center" SortExpression="Ver" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/Admin/Teste/Teste.aspx?rac=<%#Eval('idApontamento')%>" runat="server">TEXT</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
I am getting The server tag is not well formed.
in the HyperLink line.
What should I do in order to directly build a querystring in a HyperLink ?
Upvotes: 2
Views: 8914
Reputation: 100607
Build your hyperlink like this:
<asp:HyperLinkField HeaderText="Title"
DataTextField="Some Text"
DataNavigateUrlFields="idApontamento,CustomerID"
DataNavigateUrlFormatString="~/Admin/Teste/Teste.aspx?rac={0}&CustomerID={1}" />
Keep adding comma delimited values to the DataNavigateUrlFields
property, and markup the DataNavigateUrlFormatString
as you would string.Format()
Upvotes: 9
Reputation: 4746
I don't think you can embed an expression like that, you have to pick to give it all text, or all binding expression.
Thankfully, you can contatonate string in a binding expression. Try something like this:
NavigateUrl='<%# String.Concat("~/Admin/Teste/Teste.aspx?rac=", Eval("idApontamento")) %>'
Upvotes: 3
Reputation: 26190
You've got an extra double-quote after the pound (#) symbol. Does removing that help?
Upvotes: 0