Note that there are some explanatory texts on larger screens.

plurals
  1. POURL Navigation with HyperLinkField inside a gridview
    primarykey
    data
    text
    <p>I'm using a <code>HyperLinkField</code> inside a <code>gridview</code>, and I want to link to another <em>URL + an ID.</em></p> <pre><code>&lt;div id="searchResults" runat="server"&gt; &lt;asp:GridView ID="gvSearchResult" runat="server" AutoGenerateColumns = "false" CaptionAlign="NotSet" CellPadding="5"&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Användare"&gt; &lt;ItemTemplate&gt; &lt;%# Eval("UName")%&gt; &lt;br /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:HyperLinkField DataNavigateUrlFields="UName" DataNavigateUrlFormatString='/MemberPages/profile.aspx?ID=&lt;%# Eval("PID") %&gt;' DataTextField="UName" HeaderText="Besök sida" SortExpression="Name" ItemStyle-Width="100px" ItemStyle-Wrap="true" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; </code></pre> <p>The <code>gridview</code> is using <code>datasource</code> and <code>databind</code>. It's complaining about:</p> <pre><code>DataNavigateUrlFormatString="/MemberPages/profile.aspx?ID=&lt;%# Eval("PID") %&gt;" </code></pre> <p>I'm not sure where to use <code>&lt;%# Eval("PID") %&gt;</code>, I'm sure there is something like PID, I've doublechecked.</p> <p>If I'm using <code>NavigateUrl="/MemberPages/profile.aspx?ID=&lt;%# Eval("PID") %&gt;"</code> I also get the same error:</p> <pre><code>Literal content ('&lt;asp:HyperLinkField DataNavigateUrlFields="UName" DataNavigateUrlFormatString="/MemberPages/profile.aspx?ID=') is not allowed within a 'System.Web.UI.WebControls.DataControlFieldCollection'. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload