Generate K2 Buttons Based On Event Outcomes

This article shows how to dynamically generate a list of action links, based on the client event outcomes defined in the K2 process.

Reference
SourceCode.Workflow.Client

Generating the list of action buttons
public IList GenerateActionButtons(WorklistItem item, LinkAction linkAction) {    List actionLinks = new List; if (item != null) {        foreach (SourceCode.Workflow.Client.Action action in item.Actions) {            Button btnAction = new Button; btnAction.Text = action.Name; btnAction.Click += new EventHandler(linkAction); btnAction.CommandName = string.Format("{0};{1}", action.Name, item.SerialNumber); btnAction.ID = string.Format("{0}_{1}", item.ID, action.Name); btnAction.CssClass = "button"; actionLinks.Add(btnAction); }    }     return actionLinks; }

The event handler of those Buttons
public void btnAction_Click(object sender, EventArgs) {    Button actionButton = ((Button)sender); string[] arguments = actionButton.CommandName.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); wItem.Actions[arguments[0]].Execute; }