我需要生成一个动态的按钮列表,我已经这样做了,并附加了一个事件处理程序。
但是,事件处理程序没有被执行。
private void GetOptions(EcoBonusRequest request)
{
var ecobonuswworkflow = WorkflowFactory.CreateEcobonusWorkflow();
ecobonuswworkflow.SetCurrentStep(request.CurrentStatus);
var currentoptions = ecobonuswworkflow.GetCurrentOptions();
foreach(var option in currentoptions)
{
var btn = new Button() {Text = option.OptionName};
btn.Click +=new EventHandler(btn_Click);
Buttons.Controls.Add(btn);
}
}
void btn_Click(object sender, EventArgs e)
{
var btn = (Button) sender;
string command = btn.Text;
EcoBonusRequest request = this.GetDBRequest(RequestBaseId.Value);
EcoBonusRequestBL.AddWorkflowHistoryItem(request, command,CurrentUser, command);
}