关于Menu控件的子项样式定义.
我是这样绑定的数据
/*****************
* 构造菜单
* ***************/
public void CreatMenu()
{
DataTable classTable = Menutable();
DataRow[] row;
row = classTable.Select( "classPID=0 ");
mainMenu.Items.Clear();
foreach (DataRow r in row)
{
MenuItem menu = new MenuItem();
menu.Text = r[ "className "].ToString();
menu.Value = r[ "classID "].ToString();
mainMenu.Items.Add(menu);
TraversingMenu(menu);
}
}
/**********************
* 遍历子菜单
* ********************/
private void TraversingMenu(MenuItem menu)
{
DataTable classTable = Menutable();
DataRow[] row;
row = classTable.Select( "classPID= "+menu.Value);
foreach (DataRow r in row)
{
MenuItem m = new MenuItem();
m.Text = r[ "className "].ToString() + " ";
m.Value = r[ "classID "].ToString();
m.PopOutImageUrl= "images/rjiantou.gif ";
m.ImageUrl = "images/menu_l.gif ";
menu.ChildItems.Add(m);
TraversingMenu(m);
}
}
M