Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am creating an multi user application where each user have a set of webforms to be accessed and specific set not to be used(almost 30 types of profiles)

I had created two tables Menu Master and Sub menu master and Added urls and the parent child relation

I am using a Infragistic WebExplorer as Navigation control inside a usercontrol and I am doing all the data binding inside the Usercontrol codebehind.

My issue is each time when a user click the WebExplorer the control get databinded and the control is re rendered. causing application very slow Can anyone suggest me how to avoid this data binding on each postback

What I have tried:

C#
    public partial class MyMenuBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {           
                loadexplorerebar();          

        }



        public void getMenuData()
        {
            SqlCommand cmd = new SqlCommand("select * from MainMenuMaster");

            DataTable dt = ReturnQueryResultDatatable(cmd);

            SqlCommand cmd1 = new SqlCommand(@"SELECT        SubMenuMaster.Menu_PK, SubMenuMaster.MenuText, SubMenuMaster.MenuURL, SubMenuMaster.ParentID, SubMenuMaster.isEnable, SubMenuMaster.IsNormal
FROM            SubMenuMaster INNER JOIN
                         UserProfileRights ON SubMenuMaster.Menu_PK = UserProfileRights.Menu_PK
WHERE(UserProfileRights.UserProfile_Pk = @Param2)");
            cmd1.Parameters.AddWithValue("@Param2", int.Parse(Session["UserProfile_Pk"].ToString()));
            DataTable dt2 = ReturnQueryResultDatatable(cmd1);
            Session["MainMenuMaster"] = dt;
            Session["SubMenuMaster"] = dt2;

        }


        public void loadexplorerebar()
        {
            DataTable dt = null;
            DataTable dt2 = null;

            if (Session["MainMenuMaster"]==null || Session["SubMenuMaster"]==null)
            {
                getMenuData();
            }
            else
            {
                dt = (DataTable)Session["MainMenuMaster"];
                dt2 = (DataTable)Session["SubMenuMaster"];

            }            
                     

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ExplorerBarGroup grp = new ExplorerBarGroup();
                    grp.Text = dt.Rows[i]["MainmenuName"].ToString();
                    this.WebExplorerBar1.Groups.Add(grp);
                    int MAINMENU_PK = int.Parse(dt.Rows[i]["mAINmENU_pk"].ToString());
                    try
                    {

                        DataTable mainmenuchild = dt2.Select("parentid=" + MAINMENU_PK + "").CopyToDataTable();

                        foreach (DataRow drow in mainmenuchild.Rows)
                        {

                            int childid = int.Parse(drow["Menu_PK"].ToString());
                            ExplorerBarItem item = new ExplorerBarItem();
                            item.Text = drow["MenuText"].ToString();
                            item.NavigateUrl = drow["MenuURL"].ToString();
                            grp.Items.Add(item);
                            try
                            {
                                getnewItem(item, childid, dt2);
                            }
                            catch (Exception)
                            {


                            }
                        }
                    }
                    catch (Exception)
                    {


                    }


                }


            }

        }



        public void getnewItem(ExplorerBarItem item, int parentid, DataTable mainmenuchild)
        {
            if (parentid == 220)
            {
                int k = 0;
            }
            DataTable mainmenuchildtemp = mainmenuchild.Select("parentid=" + parentid + "").CopyToDataTable();
            foreach (DataRow drow in mainmenuchildtemp.Rows)
            {

                try
                {
                    int childid = int.Parse(drow["Menu_PK"].ToString());
                    ExplorerBarItem itemnum = new ExplorerBarItem();
                    itemnum.Text = drow["MenuText"].ToString();
                    itemnum.NavigateUrl = drow["MenuURL"].ToString();
                    item.Items.Add(itemnum);
                    getnewItem(itemnum, childid, mainmenuchild);
                }
                catch (Exception)
                {
                    ;
                }
            }
        }


And My HTML markup is like below

ASP.NET
<ig:WebExplorerBar ID="WebExplorerBar1" runat="server" Width="250px">
    </ig:WebExplorerBar>
Posted
Updated 20-Feb-17 13:41pm

1 solution

The real solution to get rid of full page postback is to use AJAX.

I would recommend you to also post your issue at dedicated infragistics forums since you are using infragistics controls. That way experts on that forum might be able to help you on your current issue. Developers .net Forum - Infragistics Programming Forum - User Interface Forum[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900