private void Page_Load(object sender, System.EventArgs e)
{
//定制菜单
Button BtnAll=new Button ();
BtnAll.CommandArgument ="所有栏目";
BtnAll.Text ="所有栏目";
BtnAll.Command +=new CommandEventHandler(this.OnButton);
PHMenu.Controls.Add(BtnAll);
for (int i=0;i<dtItemName.Rows.Count;i++)
{
Button Btn=new Button ();
Btn.CommandArgument =dtItemName.Rows[i]["ItemName"].ToString();
Btn.Text =dtItemName.Rows[i]["ItemName"].ToString();
Btn.Command +=new CommandEventHandler(this.OnButton);
PHMenu.Controls.Add(Btn);
}
}
public void OnButton(Object Sender, CommandEventArgs e)
{
this.InitItems(e.CommandArgument.ToString());
}
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)