Menu does not align horizontally with (Orientation)HorizontalAlign.Center

i have this menu that does not align horizontally but aligned vertically inspite of me putting

 menu.Orientation = (Orientation)HorizontalAlign.Center;

protected void Page_PreInit(object sender, EventArgs e)
        {
            Page.Theme = AdminLogin.GetTheme("Admin");

            if (!firsttimeload)
            {


                Page.Controls.Remove(Panel01);
                Page.DataBind();

                PopulateMenu();

                //firsttimeload = false;
            }
            else
            {
                PopulateMenu();
                firsttimeload = false;
            }
        }

    } 

void PopulateMenu()
        {
            #region Menu Generate

            using (SqlConnection sqlconn = new SqlConnection(connstring))
            {
                DataSet ds1 = new DataSet();

                //string strSQL1 = "select * from AdminMenuParentGrant where GrantPersonType = '" + Session["uname"] + "'";
                string strSQL1 = "select * from AdminMenuParentGrant where GrantPersonType = 'Admin'";
                SqlDataAdapter adapter1 = new SqlDataAdapter(strSQL1, sqlconn);
                adapter1.Fill(ds1);

                count_parentid = ds1.Tables[0].Rows.Count;

                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {


                    list_parentid.Add(Convert.ToInt32(ds1.Tables[0].Rows[i]["PUniqueNumber"]));


                }

                DataSet ds3 = new DataSet();


                menu = new Menu();

                for (int j = 0; j < count_parentid; j++)
                {


                    string strSQL3 = "select * from AdminMenuParent WHERE UniqueNumber = " + list_parentid[j];
                    SqlDataAdapter adapter = new SqlDataAdapter(strSQL3, sqlconn);
                    adapter.Fill(ds3);

                    string sMenuParentItem = ds3.Tables[0].Rows[j]["MenuParentItem"].ToString();
                    string sCssStaticHoverStyle = ds3.Tables[0].Rows[j]["CssStaticHoverStyle"].ToString();
                    string sCssDynamicHoverStyle = ds3.Tables[0].Rows[j]["CssDynamicHoverStyle"].ToString();

                    string sMenuItemStyle1 = ds3.Tables[0].Rows[j]["MenuItemStyle1"].ToString();
                    string sMenuItemStyle2 = ds3.Tables[0].Rows[j]["MenuItemStyle2"].ToString();
                    string sMenuItemStyle3 = ds3.Tables[0].Rows[j]["MenuItemStyle3"].ToString();

                    MenuItem categoryItem = new MenuItem(sMenuParentItem);
                    menu.Items.Add(categoryItem);

                    menu.Orientation = (Orientation)HorizontalAlign.Center;
                   
                    menu.StaticHoverStyle.CssClass = sCssStaticHoverStyle;
                    menu.DynamicHoverStyle.CssClass = sCssDynamicHoverStyle;

                    MenuItemStyle menuitemstyle1 = new MenuItemStyle();
                    menuitemstyle1.CssClass = sMenuItemStyle1;

                    MenuItemStyle menuitemstyle2 = new MenuItemStyle();
                    menuitemstyle2.CssClass = sMenuItemStyle2;

                    MenuItemStyle menuitemstyle3 = new MenuItemStyle();
                    menuitemstyle3.CssClass = sMenuItemStyle3;

                    menu.LevelMenuItemStyles.Add(menuitemstyle1);
                    menu.LevelMenuItemStyles.Add(menuitemstyle2);
                    menu.LevelMenuItemStyles.Add(menuitemstyle3);

                    DataSet ds99 = new DataSet();
                    string strSQL99 = "Select * from AdminMenuChild where PUniqueNumber = " + list_parentid[j];
                    SqlDataAdapter adapter99 = new SqlDataAdapter(strSQL99, sqlconn);
                    adapter99.Fill(ds99);

                    for (int z = 0; z < ds99.Tables[0].Rows.Count; z++)
                    {
                        MenuItem childrenItem = new MenuItem(ds99.Tables[0].Rows[z]["MenuChildItem"].ToString());
                        childrenItem.NavigateUrl = ds99.Tables[0].Rows[z]["MenuURL"].ToString();
                        categoryItem.ChildItems.Add(childrenItem);
                    }

                    Panel01.Controls.Add(menu);
                    Panel01.DataBind();

                }


            }
            #endregion

        }

Open in new window

LVL 1
doramail05Asked:
Who is Participating?
 
robastaCommented:
Line 73 should be like this:

 menu.Orientation = Orientation.Horizontal;

not this:

    menu.Orientation = (Orientation)HorizontalAlign.Center;

0
 
masterpassCommented:
Can you try

menu.Orientation = Orientation.Horizontal;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.