commandargument string not evaluating
<p>I have a commandargument inside an aspx page set to an object variable inside a for loop as below:</p>

<pre><code>&lt;% foreach (PromotionImage p in imageList)
    { 
 %&gt;
     &lt;asp:LinkButton runat="server" OnCommand="deleteButton_Click" ID="deleteButton" CommandArgument="&lt;%# p.ImageId.ToString(); %&gt;" ForeColor="Red"
                            OnClientClick="javascript:return confirm('Are you sure you want to delete this item?');"&gt;X&lt;/asp:LinkButton&gt;
&lt;%
     }
%&gt;
</code></pre>

<p>Then in my c# code behind I have the following to try to get this value:</p>

<pre><code>protected void deleteButton_Click(object sender, CommandEventArgs e)
        {
            int imageId = System.Convert.ToInt32(e.CommandArgument.ToString());
        }
</code></pre>

<p>However the c# code keeps returning "System.FormatException: Input string was not in a correct format."</p>

<p>When debugging the e.CommandArgument contains the string "&lt;%# p.ImageId.ToString(); %>" rather than the actual ImageId, why is it not evaluating? Though all my other variables evaluate fine?</p>
