DataSet ds = new DataSet(); DataTable dt = new DataTable(); string sql = "Select * from Menu"; SqlDataAdapter da = new SqlDataAdapter(sql, con); da.Fill(ds); dt = ds.Tables[0]; DataRow[] drowpar = dt.Select("ParentID=" + 0); foreach (DataRow dr in drowpar) { menuBar.Items.Add(new MenuItem(dr["MenuName"].ToString(), dr["MenuID"].ToString(), "", dr["MenuLocation"].ToString())); } foreach (DataRow dr in dt.Select("ParentID >" + 0)) { MenuItem mnu = new MenuItem(dr["MenuName"].ToString(), dr["MenuID"].ToString(), "", dr["MenuLocation"].ToString()); menuBar.FindItem(dr["ParentID"].ToString()).ChildItems.Add(mnu); }
Quote:Prabhat Kr. Singh
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)