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:TemplateFie开发者_如何学编程ld>
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 ?
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()
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")) %>'
You've got an extra double-quote after the pound (#) symbol. Does removing that help?
精彩评论