Exemple #1
0
        public void GetAccessOleDb()
        {
            Grid grid = new Grid();

            grid.Sql              = "SELECT * FROM Employees";
            grid.ID               = "test";
            grid.Page             = Testpage;
            grid.PageLength       = 2;
            grid.ConnectionString = ConnectionAccessOleDb;

            WebGrid.GridPart part1 = new WebGrid.GridPart();
            part1.Page         = Testpage;
            part1.MasterGrid   = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.NewRecord;
            part1.ID           = "part1";
            part1.Html         = "New Record Button";
            Testpage.Controls.Add(part1);


            WebGrid.GridPart part2 = new WebGrid.GridPart();
            part1.Page         = Testpage;
            part1.MasterGrid   = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.Pager;
            part1.ID           = "part2";
            Testpage.Controls.Add(part2);

            WebGrid.GridPart part3 = new WebGrid.GridPart();
            part1.Page         = Testpage;
            part1.MasterGrid   = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.SearchField;
            part1.ID           = "part3";
            Testpage.Controls.Add(part3);


            WebGrid.GridPart part4 = new WebGrid.GridPart();
            part1.Page         = Testpage;
            part1.MasterGrid   = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.UpdateRecords;
            part1.ID           = "part4";
            Testpage.Controls.Add(part4);

            Testpage.Controls.Add(grid);

            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            Testpage.RenderControl(gridwriter);
            Console.WriteLine(sb.ToString());
        }
Exemple #2
0
        public void GetAccessOleDb()
        {
            Grid grid = new Grid();
            grid.Sql = "SELECT * FROM Employees";
            grid.ID = "test";
            grid.Page = Testpage;
            grid.PageLength = 2;
            grid.ConnectionString = ConnectionAccessOleDb;

            WebGrid.GridPart part1 = new WebGrid.GridPart();
            part1.Page = Testpage;
            part1.MasterGrid = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.NewRecord;
            part1.ID = "part1";
            part1.Html = "New Record Button";
            Testpage.Controls.Add(part1);

            WebGrid.GridPart part2 = new WebGrid.GridPart();
            part1.Page = Testpage;
            part1.MasterGrid = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.Pager;
            part1.ID = "part2";
            Testpage.Controls.Add(part2);

            WebGrid.GridPart part3 = new WebGrid.GridPart();
            part1.Page = Testpage;
            part1.MasterGrid = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.SearchField;
            part1.ID = "part3";
            Testpage.Controls.Add(part3);

            WebGrid.GridPart part4 = new WebGrid.GridPart();
            part1.Page = Testpage;
            part1.MasterGrid = grid.ID;
            part1.GridPartType = WebGrid.Enums.GridPart.UpdateRecords;
            part1.ID = "part4";
            Testpage.Controls.Add(part4);

            Testpage.Controls.Add(grid);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            Testpage.RenderControl(gridwriter);
            Console.WriteLine(sb.ToString());
        }
Exemple #3
0
        private static GridPart FindControls(string masterEditorID, ControlCollection controls,
                                             Enums.GridPart controlTypeSearchFor)
        {
            // Search the children of this control
            for (int i = 0; i < controls.Count; i++)
            {
                if (controls[i] is GridPart == false)
                {
                    continue;
                }

                GridPart found = (GridPart)controls[i];
                if (found.GridPartType != controlTypeSearchFor ||
                    String.Compare(found.MasterGrid, masterEditorID, true) != 0)
                {
                    continue;
                }
                return(found);
            }

            // Start searching the children of the children of this control
            for (int i = 0; i < controls.Count; i++)
            {
                if (controls[i].Controls.Count == 0)
                {
                    continue;
                }

                GridPart found = FindControls(masterEditorID, controls[i].Controls, controlTypeSearchFor);
                if (found != null)
                {
                    return(found);
                }
            }

            // Oops!
            return(null);
        }