CommandArgument confusion!

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: PaulM (anonymous_at_discussions.microsoft.com)
Date: 06/01/04


Date: Tue, 1 Jun 2004 12:01:08 -0700

I have a linkbutton thats nested in a DataList that I use for deleting records. I can successfully use this linkbutton as long as the CommandName and CommandArgument are set in the aspx file, as follows.

<asp:LinkButton ID="lnkrskDelete" CommandName="Delete" CommandArgument="123" Runat=server>Delete</asp:LinkButton>

However, I need to dynamically change the CommandArgument (its the key to the data) for every record. I've accessed the LinkButton during the ItemCreatedEvent for the datalist, and am setting the CommandArgument property as follows.

((LinkButton) e.Item.FindControl("lnkrskDelete")).CommandArgument = currentRisk.RiskId.ToString();

However when the Delete Event fires the CommandArgument is an empty string.

Any suggestions would be greatly appreciated.

thanks,
Paul M


Quantcast