コード例 #1
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void GetEmployeesAccessMasterGrid()
        {
            Grid mastergrid = new Grid
                                  {
                                      DataSourceId = "Employees",
                                      ID = "test",
                                      Page = Testpage,
                                      ConnectionString = ConnectionAccessOleDb
                                  };
            Testpage.Controls.Add(mastergrid);

            Grid slavegrid = new Grid
                                 {
                                     DataSourceId = "Territories",
                                     ID = "test2",
                                     Page = Testpage,
                                     MasterGrid = "test",
                                     ConnectionString = ConnectionAccessOleDb
                                 };
            Testpage.Controls.Add(slavegrid);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            slavegrid.RenderControl(gridwriter);

            Assert.Greater(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.IsFalse(slavegrid.MasterTable.GotSchema);
        }
コード例 #2
0
ファイル: ColumnValue.cs プロジェクト: webgrid/WebGrid
        public void GridRowBoundAllowEditInRow()
        {
            //Update The record set, we are updating record set 11
            SqlConnectionUpdate();

            Grid grid = new Grid();
            SetupTestGrid(grid);
            grid.PageSize = 100;
            grid.Culture = new System.Globalization.CultureInfo("en-US");
            grid.RowHighLight = System.Drawing.Color.Azure;
            ((WebGrid.DateTime)grid["dtmDate"]).Format = dateformat;
            grid.RaisePostBackEvent("RecordCancelClick!");
            grid.GridRowBound += grid_GridRowBound;
            grid["intTest"].AllowEditInGrid = true;
            grid["decTest"].AllowEditInGrid = true;
            grid["dtmDate"].AllowEditInGrid = true;
            grid["vchtest"].AllowEditInGrid = true;
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, 1);

            // These are triggers from html being rendered.

            string[] triggerStrings = new[]
                                          {
                                               "wggrid_40_vchTest",
                                              "wggrid_40_decTest",
                                              "wggrid_40_intTest",
                                              "wggrid_40_dtmDate",
                                      //        "wggrid_40_dtmDate_trigger",
                                              "cb_wggrid_40_bitFlag",
                                              "wggrid_40_bitFlag",
                                              "onmouseover=\"wgrowhighlight",
                                        //      "calendar.gif",
                                              "wggrid_11_vchTest",
                                              "wggrid_11_decTest",
                                              "wggrid_11_intTest",
                                              "wggrid_11_dtmDate",
                                      //        "wggrid_11_dtmDate_trigger",
                                              "cb_wggrid_11_bitFlag",
                                              "wggrid_11_bitFlag",
                                              //DateTime column with today's DateTime
                                              "value=\""+DateTime.Now.ToString(dateformat)+"\" id=\"wggrid_11_dtmDate\"",
                                              //Test column with 'blah'+ DateTime
                                         //    "maxlength=\"50\"  value=\"blah" +DateTime.Now.ToString(dateformat)+"\" id=\"wggrid_11_vchTest\"",
                                           //Decimal column with value 5634 formatted default "N2"
                                            "style=\"text-align: Right;\" value=\"5,634.00\" id=\"wggrid_11_decTest\"",
                                            //Number column with 33345 formatted default with "N0"
                                            "style=\"text-align: Right;\" value=\"33,345\" id=\"wggrid_11_intTest\""
                                          };

            string content = sb.ToString();
            foreach (string part in triggerStrings)
            {
                int res = content.IndexOf(part);
                Assert.Greater(res, -1,part+Environment.NewLine+content);
            }
        }
コード例 #3
0
ファイル: Rendering.cs プロジェクト: webgrid/WebGrid
        public void RenderEmptyGrid()
        {
            Grid grid = new Grid();

            grid.ID = "test";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
        }
コード例 #4
0
ファイル: Grouping.cs プロジェクト: webgrid/WebGrid
 public void SqlServerGrouping()
 {
     Grid grid = new Grid();
     SetupSqlServerGrid(grid);
     grid.GroupByExpression = "ProductID";
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.Greater(grid.MasterTable.Rows.Count, 1);
 }
コード例 #5
0
ファイル: Exception.cs プロジェクト: webgrid/WebGrid
 public void GetUnknownDataSource()
 {
     Grid grid = new Grid();
     grid.DataSourceId = "UnKnown";
     grid.ID = "test";
     grid.Page = Testpage;
     grid.ConnectionString = ConnectionAccessOleDb;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
 }
コード例 #6
0
ファイル: Exception.cs プロジェクト: webgrid/WebGrid
 public void GetEmployeesErrorWhere()
 {
     Grid grid = new Grid();
     grid.DataSourceId = "Employees";
     grid.ID = "test";
     grid.Where = "ErrorInWhere";
     grid.ConnectionString = ConnectionAccessOleDb;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
 }
コード例 #7
0
ファイル: ColumnValue.cs プロジェクト: webgrid/WebGrid
 public void GridRowBound()
 {
     Grid grid = new Grid();
     SetupTestGrid(grid);
     grid.RaisePostBackEvent("RecordCancelClick!");
     grid.GridRowBound += grid_GridRowBound;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.Greater(grid.MasterTable.Rows.Count, 1);
 }
コード例 #8
0
ファイル: Exception.cs プロジェクト: webgrid/WebGrid
 public void GetEmployeesAccessInvalidMasterGrid()
 {
     Grid grid = new Grid();
     grid.DataSourceId = "Employees";
     grid.ID = "test";
     grid.Page = Testpage;
     grid.MasterGrid = "NotFound";
     grid.ConnectionString = ConnectionAccessOleDb;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
 }
コード例 #9
0
ファイル: Properties.cs プロジェクト: webgrid/WebGrid
 public void GetAccessOleDBAllowEditInGridTrue()
 {
     var grid = new Grid {Sql = "SELECT * FROM Employees", ID = "test"};
     grid["FirstName"].AllowEditInGrid = true;
     grid["LastName"].AllowEditInGrid = true;
     grid.DefaultVisibility = Visibility.Both;
     grid.ConnectionString = ConnectionAccessOleDb;
     var sb = new StringBuilder();
     var sw = new StringWriter(sb);
     var gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.AreEqual(grid.AllowEditInGrid, true);
 }
コード例 #10
0
ファイル: DataSource.cs プロジェクト: webgrid/WebGrid
 public void GetAccessOleDb()
 {
     Grid grid = new Grid();
     grid.Sql = "SELECT * FROM Employees";
     grid.ID = "test";
     grid.Page = Testpage;
     grid.ConnectionString = ConnectionAccessOleDb;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.Greater(grid.MasterTable.Rows.Count, 1);
 }
コード例 #11
0
ファイル: Exception.cs プロジェクト: webgrid/WebGrid
 public void GetEmployeesErrorWhere()
 {
     Grid grid = new Grid
                     {
                         DataSourceId = "Employees",
                         ID = "test",
                         FilterExpression = "ErrorInWhere",
                         ConnectionString = ConnectionAccessOleDb
                     };
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
 }
コード例 #12
0
ファイル: DataSourceGeneric.cs プロジェクト: webgrid/WebGrid
        public void LoadGridWithEmployeesGenericDictionary()
        {
            NorthwindEmployeeData employeedata = new NorthwindEmployeeData();

            Dictionary<int,NorthwindEmployee> employees = employeedata.GetAllEmployeesDictionary("", 0, 100);

            Grid grid = new Grid();
            grid.DataSource = employees;
            grid.ID = "test";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, employees.Count);
        }
コード例 #13
0
ファイル: Properties.cs プロジェクト: webgrid/WebGrid
 public void GetAccessOleDBAllowEditInGridTFalse()
 {
     var grid = new Grid
                    {
                        Sql = "SELECT * FROM Employees",
                        ID = "test",
                        DefaultVisibility = Visibility.Both,
                        ConnectionString = ConnectionAccessOleDb
                    };
     var sb = new StringBuilder();
     var sw = new StringWriter(sb);
     var gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.AreEqual(grid.AllowEditInGrid, false);
 }
コード例 #14
0
ファイル: DataSource.cs プロジェクト: webgrid/WebGrid
 public void GetAccessOleDbCacheIsFalse()
 {
     Grid grid = new Grid();
     grid.Sql = "SELECT * FROM Employees";
     grid.ID = "test";
     grid.CacheGridStructure = false;
     grid.ConnectionString = ConnectionAccessOleDb;
     grid.Page = Testpage;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.Greater(grid.MasterTable.Rows.Count, 1);
     Assert.IsFalse(grid.MasterTable.CacheDatasourceStructure);
     Assert.IsFalse(grid.MasterTable.GotDataSourceCache);
 }
コード例 #15
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void CreateAndDeleteRecord()
        {
            CreateRecordSelect();

            int CategoryId = GetCategoryId();

            Grid grid = new Grid();
            Testpage.Controls.Add(grid);
            SetDataSource(grid);
            grid.ID = "test";
            grid.DefaultVisibility = Visibility.Both;
            grid.RecordsPerRow = 2;
            grid.PagerSettings.PagerType = PagerType.Standard;
            grid.Width = Unit.Pixel(1000);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.DataSourceType, DataSourceControlType.AccessDataSource);
            int records = grid.MasterTable.Rows.Count;

            grid = new Grid();
            Testpage.Controls.Add(grid);
            SetDataSource(grid);
            grid.ID = "test";
            grid.DefaultVisibility = Visibility.Both;
            grid.RecordsPerRow = 2;
            grid.PagerSettings.PagerType = PagerType.Standard;
            grid.Width = Unit.Pixel(1000);
            grid.RaisePostBackEvent(string.Format("RecordDeleteClick!{0}", CategoryId));

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            ////grid.ReLoadData = true;
            grid.RenderControl(gridwriter);

             //   Assert.AreEqual(grid.MasterTable.Rows.Count,  GetCategoryCount());
            //   Assert.AreEqual(records-1, grid.MasterTable.Rows.Count);
            Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
            Assert.LessOrEqual(grid.SystemMessage.Count, 1);
        }
コード例 #16
0
ファイル: PostBackClick.cs プロジェクト: webgrid/WebGrid
        public void CreateAndDeleteRecord()
        {
            CreateRecord();

            string CategoryId =
                Query.ExecuteScalar("SELECT TOP 1 CategoryID FROM Categories ORDER BY CategoryID DESC",
                                    ConnectionAccessOleDb).ToString();

            Grid grid = new Grid();
            grid.DataSourceId = "Categories";
            grid.ID = "test";
            grid.ConnectionString = ConnectionAccessOleDb;
            grid.DefaultVisibility = Visibility.Both;
            grid.RecordsPerRow = 2;
            grid.PagerSettings.PagerType = PagerType.None;
            grid.Width = Unit.Pixel(1000);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            int records = grid.MasterTable.Rows.Count;

            grid = new Grid();
            grid.DataSourceId = "Categories";
            grid.ID = "test";
            grid.ConnectionString = ConnectionAccessOleDb;
            grid.DefaultVisibility = Visibility.Both;
            grid.RecordsPerRow = 2;
            grid.PagerSettings.PagerType = PagerType.None;
            grid.Width = Unit.Pixel(1000);
            grid.RaisePostBackEvent("RecordDeleteClick!" + CategoryId);

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            grid.MasterTable.GetData(true);
            grid.RenderControl(gridwriter);

               //     Assert.Less(grid.MasterTable.Rows.Count, records);
            Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
        }
コード例 #17
0
ファイル: Rendering.cs プロジェクト: webgrid/WebGrid
 public void GetEmployeesAccessLayOutTest()
 {
     Grid grid = new Grid();
     grid.DataSourceId = "Employees";
     grid.ID = "test";
     grid.RecordsPerRow = 2;
     grid.PagerType = PagerType.None;
     grid.Width = Unit.Pixel(1000);
     grid.Height = Unit.Pixel(1500);
     PlaceHolder helptext = new PlaceHolder();
     Label label = new Label();
     label.Text = "This is an test..";
     helptext.Controls.Add(label);
     grid.HelpText = helptext;
     grid.ConnectionString = ConnectionAccessOleDb;
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
     grid.RenderControl(gridwriter);
     Assert.Greater(grid.MasterTable.Rows.Count, 1);
     Assert.AreNotSame(sb.ToString().IndexOf("is an test.."), -1);
 }
コード例 #18
0
ファイル: ColumnFeature.cs プロジェクト: webgrid/WebGrid
        public void AllowEditInGrid()
        {
            Grid grid = new Grid();

            SetupGrid(grid);

            grid["CategoryName"].AllowEditInGrid = true;
            grid["Description"].AllowEditInGrid = true;
            grid["CategoryId"].AllowEditInGrid = true;
            grid["CategoryId"].Visibility = Visibility.Both;

            Assert.AreEqual(grid.Mode, Mode.Edit);
            grid.RaisePostBackEvent("RecordCancelClick!");

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.Mode, Mode.Grid);
            Assert.LessOrEqual(grid.SystemMessage.Count, 1);
            Assert.Greater(grid.Rows.Count, 1);
        }
コード例 #19
0
ファイル: DataSourceGeneric.cs プロジェクト: webgrid/WebGrid
        public void LoadGridWithNumbers()
        {
            List<int> numbers = new List<int>();
            numbers.Add(45);
            numbers.Add(45);
            numbers.Add(34);
            numbers.Add(34);
            numbers.Add(34);
            numbers.Add(23);
            numbers.Add(45);
            numbers.Add(45);
            numbers.Add(23);

            Grid grid = new Grid();
            grid.DataSource = numbers;
            grid.ID = "test";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, numbers.Count);
        }
コード例 #20
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void GetEmployeesAccessMasterGridEdit()
        {
            Grid mastergrid = new Grid();
            mastergrid.DataSourceId = "Employees";
            mastergrid.ID = "test";
            mastergrid.Page = Testpage;
            mastergrid.EditIndex = "3";
            mastergrid["Photo"].Visibility = Visibility.None; //HtmlForm is required for File columns.
            mastergrid.DisplayView = DisplayView.Detail;
            mastergrid.ConnectionString = ConnectionAccessOleDb;
            Testpage.Controls.Add(mastergrid);

            Grid slavegrid = new Grid();
            slavegrid.DataSourceId = "Territories";
            slavegrid.ID = "test2";
            slavegrid.Page = Testpage;
            slavegrid.MasterGrid = "test";
            slavegrid.ConnectionString = ConnectionAccessOleDb;
            Testpage.Controls.Add(slavegrid);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            slavegrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsFalse(slavegrid.MasterTable.GotSchema);
        }
コード例 #21
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void SetDataSourceForeignKeyStringArray()
        {
            Grid mastergrid = new Grid();

            mastergrid.ID = "test";
            mastergrid.Page = Testpage;

            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Foreignkey column = new Foreignkey("ForeignkeyItems", mastergrid.MasterTable);
            column.NullText = "Select Category";
            column.Required = true;
            mastergrid.MasterTable.Columns.Add(column);

            WebGrid.Data.Table fktable = new WebGrid.Data.Table(mastergrid, true);
            string[] names = new[] { "Tom", "Dick", "Harry", "Thomas", "Anders", "Carl", "Trond", "Eli", "Eva" };
            fktable.DataSource = names;

            ((Foreignkey)mastergrid["ForeignkeyItems"]).Table = fktable;

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, names.Length);
        }
コード例 #22
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void SetDataSourceForeignKeyGetDataForce()
        {
            Grid mastergrid = new Grid();

            mastergrid.ID = "test";
            mastergrid.Page = Testpage;

            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Foreignkey column = new Foreignkey("ForeignkeyItems", mastergrid.MasterTable);
            column.NullText = "Select Category";
            column.Required = true;
            mastergrid.MasterTable.Columns.Add(column);

            WebGrid.Data.Table fktable = new WebGrid.Data.Table(mastergrid, true);
            StringDictionary tmp = new StringDictionary();

            tmp.Add("Category 1", "1");
            tmp.Add("Category 2", "2");
            tmp.Add("Category 3", "3");
            tmp.Add("Category 4", "4");
            tmp.Add("Category 5", "5");
            tmp.Add("Category 6", "6");
            tmp.Add("Category 7", "7");
            fktable.DataSource = tmp;

            ((Foreignkey)mastergrid["ForeignkeyItems"]).Table = fktable;
            ((Foreignkey)mastergrid["ForeignkeyItems"]).ValueColumn = "Value";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, 7);
            ((Foreignkey) mastergrid["ForeignkeyItems"]).Table.FilterExpression = "Value = 3";

            Assert.AreEqual(((Foreignkey)mastergrid["ForeignkeyItems"]).Table.Rows.Count, 1);
        }
コード例 #23
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void GetEmployeesAccessMasterGridSetDataSource()
        {
            //Setting up a standard OleDBDataAdapter datasource.
            OleDbConnection myConn = new OleDbConnection(ConnectionAccessOleDb);

            OleDbDataAdapter myCmdEmployee = new OleDbDataAdapter("SELECT * FROM [Employees]", myConn);
            OleDbDataAdapter myCmdTerritories = new OleDbDataAdapter("SELECT * FROM [Territories]", myConn);

            Grid mastergrid = new Grid();
            mastergrid.DataSource = myCmdEmployee;
            mastergrid.ID = "test";
            mastergrid.Page = Testpage;
            Testpage.Controls.Add(mastergrid);

            Grid slavegrid = new Grid();
            slavegrid.DataSourceId = "Territories";
            slavegrid.DataSource =myCmdTerritories;
            slavegrid.ID = "test2";
            slavegrid.Page = Testpage;
            slavegrid.MasterGrid = "test";
            Testpage.Controls.Add(slavegrid);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            slavegrid.RenderControl(gridwriter);

            Assert.Greater(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(mastergrid.MasterTable.GotSchema);
            Assert.IsFalse(slavegrid.MasterTable.GotSchema);
        }
コード例 #24
0
ファイル: Relations.cs プロジェクト: webgrid/WebGrid
        public void GetEmployeesAccessMasterGridEditSetDataSource()
        {
            //Setting up a standard OleDBDataAdapter datasource.
            OleDbConnection myConn = new OleDbConnection(ConnectionAccessOleDb);

            OleDbDataAdapter myCmdEmployee = new OleDbDataAdapter("SELECT * FROM [Employees]", myConn);
            OleDbDataAdapter myCmdTerritories = new OleDbDataAdapter("SELECT * FROM [Territories]", myConn);

            Grid mastergrid = new Grid();
            mastergrid.DataSource = myCmdEmployee;
            mastergrid.ID = "test";
            mastergrid.Page = Testpage;
            mastergrid.EditIndex = "3";
            mastergrid["Photo"].Visibility = Visibility.None; //HtmlForm is required for File columns.
            mastergrid.DisplayView = DisplayView.Detail;
            Testpage.Controls.Add(mastergrid);

            Grid slavegrid = new Grid();
            slavegrid.DataSource = myCmdTerritories;
            slavegrid.ID = "test2";
            slavegrid.Page = Testpage;
            slavegrid.MasterGrid = "test";
            Testpage.Controls.Add(slavegrid);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            mastergrid.RenderControl(gridwriter);

            sb = new StringBuilder();
            sw = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            slavegrid.RenderControl(gridwriter);

            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.IsFalse(slavegrid.MasterTable.GotSchema);
        }
コード例 #25
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void CreateRecordSelect()
        {
            Grid grid = new Grid();
            Testpage.Controls.Add(grid);
            grid = CreateNewCategorySelect(grid);
            grid["CategoryID"].Visibility = Visibility.None;
            int records = grid.MasterTable.Rows.Count;

            Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
            grid.RaisePostBackEvent("RecordUpdateClick!!False");
            Assert.AreEqual(grid.SystemMessage.Count, 0);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            ////grid.ReLoadData = true;
            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, records);

            Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
        }
コード例 #26
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void UpdateRecordStayInDetail()
        {
            Grid grid = new Grid();
            Testpage.Controls.Clear();
            Testpage.Controls.Add(grid);
            grid = SelectAccessCategories(grid);
            grid.EditIndex = "6";
            grid.StayInDetail = true;
            int records = grid.MasterTable.Rows.Count;

            Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
            grid.RaisePostBackEvent("RecordUpdateClick!!False");
            Assert.AreEqual(grid.SystemMessage.Count, 0);

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            ////grid.ReLoadData = true;
            grid.RenderControl(gridwriter);

            Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
            Assert.AreEqual(grid.MasterTable.Rows.Count, records);
            Assert.AreEqual(grid.SystemMessage.Count, 0);
        }
コード例 #27
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void SelectFromXmlDataSourceEditUpdate()
        {
            Grid grid = new Grid();

            SetupGrid(grid);

            XmlDataSource ds = new XmlDataSource();
            ds.XPath = "//Language//*";
            ds.ID = "test1";
            ds.DataFile = Path + "\\WebGridMessages.xml";
            Testpage.Controls.Add(ds);
            grid.DataSourceId = ds.ID;
            grid["LanguageID"].Primarykey = true;
            grid.EditIndex = "Norwegian";
            grid.DisplayView = DisplayView.Detail;
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            string text = "T:" + DateTime.Now.Ticks;
            grid.Rows[0]["PagerPrefix"].Value = text;
            grid.BeforeUpdateInsert += grid_BeforeUpdateInsert;
            grid.RaisePostBackEvent("RecordUpdateClick!Norwegian!False");
            grid.RenderControl(gridwriter);
            Assert.Greater(grid.Rows.Count, 1, sb.ToString());
            Assert.LessOrEqual(grid.SystemMessage.Count, 1);

            string filecontent = System.IO.File.ReadAllText(Path + "\\WebGridMessages.xml");
            Assert.Greater(filecontent.IndexOf(text), 0);

               /* string[] triggerStrings = new[]
                                          {
                                              "Forrige side",
                                              "RecordCancelClick!Norwegian!",
                                              "RecordUpdateClick!Norwegian!False"
                                          };
            string content = sb.ToString();
            foreach (string part in triggerStrings)
            {
                int res = content.IndexOf(part);
                Assert.Greater(res, -1, part + Environment.NewLine + content);
            }
            */
        }
コード例 #28
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void SelectFromXmlDataSourceEdit()
        {
            Grid grid = new Grid();

            SetupGrid(grid);

            XmlDataSource ds = new XmlDataSource();
            ds.XPath = "//Language//*";
            ds.ID = "test1";
            ds.DataFile = Path + "\\WebGridMessages.xml";
            Testpage.Controls.Add(ds);
            grid.DataSourceId = ds.ID;
            grid["LanguageID"].Primarykey = true;
            grid.RaisePostBackEvent("RecordClick!!Norwegian");

            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, 1);
            Assert.LessOrEqual(grid.SystemMessage.Count, 1);

            string[] triggerStrings = new[]
                                          {
                                              "Forrige side",
                                              "RecordCancelClick!Norwegian!",
                                              "RecordUpdateClick!Norwegian!False"
                                          };
            string content = sb.ToString();
            foreach (string part in triggerStrings)
            {
                int res = content.IndexOf(part);
                Assert.Greater(res, -1, part + Environment.NewLine + content);
            }
        }
コード例 #29
0
ファイル: DataSourceGeneric.cs プロジェクト: webgrid/WebGrid
        public void LoadGridWithNames()
        {
            List<string> names = new List<string>();
            names.Add("Tom");
            names.Add("Dick");
            names.Add("Harry");
            names.Add("Thomas");
            names.Add("Anders");
            names.Add("Carl");
            names.Add("Trond");
            names.Add("Eli");
            names.Add("Eva");

            Grid grid = new Grid();
            grid.DataSource = names;
            grid.ID = "test";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, names.Count);
        }
コード例 #30
0
ファイル: DataSourceControl.cs プロジェクト: webgrid/WebGrid
        public void SelectFromXmlDataSourceControlSearch()
        {
            Grid grid = new Grid();

            SetupGrid(grid);

            XmlDataSource ds = new XmlDataSource();
            ds.XPath = "//Language//*";
            ds.ID = "test1";
            ds.DataFile = Path + "\\WebGridMessages.xml";
            Testpage.Controls.Add(ds);
            grid.DataSourceId = ds.ID;
            grid["LanguageID"].Primarykey = true;
            grid.Search = "\"a\" -t";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, 6);
        }