title: ASP.Net LinkButton CommandArgument property ignores <%= .. %>
body: <p>I'm trying to do what I thought was a very simple operation to set a property on an ASP.Net LinkButton control but for some reason ASP.Net is ignoring the tags and just passing through the value as a string.</p>
  
  <pre><code>&lt;asp:LinkButton id="viewDetails" runat="server" Text="Details" OnClick="btnDetails_Click" CommandName="ItemID" CommandArgument="&lt;%= item.ItemID %&gt;" /&gt;
  </code></pre>
  
  <p>When the link is clicked I handle it with:</p>
  
  <pre><code>   protected void btnDetails_Click(object sender, EventArgs e)
     {
         try
         {
             LinkButton btn = (LinkButton)sender;
             if (btn.CommandName == "ItemID")
             {
                 string itemID = btn.CommandArgument.ToString();               
             }
         }
         catch (Exception excp)
         {
             lblError.ForeColor = System.Drawing.Color.Red;
             lblError.Text = excp.Message;
         }
     }
  </code></pre>
  
  <p>The problem is itemID ends up with a value of "&lt;%= item.ItemID %>".</p>
  
  <p>I've seen other people encounter the same issue and try things like the below but none have worked for me so far.</p>
  
  <pre><code>&lt;asp:LinkButton id="viewDetails" runat="server" Text="Details" OnClick="btnDetails_Click" CommandName="ItemID" CommandArgument=&lt;%= item.ItemID %&gt; /&gt;
  
  &lt;asp:LinkButton id="viewDetails" runat="server" Text="Details" OnClick="btnDetails_Click" CommandName="ItemID" CommandArgument="&lt;%# item.ItemID %&gt;" /&gt;
  </code></pre>