C# and ASP - Setting a command argument, then command argument disappearing
<p>I'm trying to use a gridviewcommand to delete an entry in the gridview (as well as from the datacontext), but I want to ask the user to confirm or not first. I have a seperate linkbutton to execute the delete code using the ID of the item in the row that the user clicked the delete button in. </p>

<p>When the user clicks delete, my codebehind sets the CommandArgument property of the other linkbutton to basically be the same command argument that it passed. But when the user goes to confirm the deletion, all of a sudden the commandargument of the confirmation link is an empty string? Is the property being flushed after the first postback?</p>

<p>Here is my code:</p>

<p>ASPX</p>

<pre><code>&lt;asp:LinkButton ID="lbDelete" runat="server" Text="Delete" CommandName="delete" CommandArgument='&lt;%# Eval("TheId") %&gt;' /&gt; //Delete LinkButton

&lt;asp:LinkButton ID="confirmDelete" runat="server" OnClick="confirmDelete_Click" Text="Delete" /&gt; //Confirmation Button
</code></pre>

<p>C#</p>

<pre><code>rowCommandFunction(object sender, GridViewCommandEventArgs e)
{
     // blah blah blah
     ...
     confirmDelete.CommandArgument = e.CommandArgument.ToString();
     ...// I've put a breakpoint here, and it is setting the value properly...
}

confirmDelete_Click(object sender, EventArgs e)
{
    //...but when this line tries to run, comfirmDelete.CommandArgument is set to an empty string?
    int selectedId = int.Parse(confirmDelete.CommandArgument);
    ...
}
</code></pre>
