public void LoadGridWithNeedDataDetailView() { Grid grid = new Grid(); grid.DataBind(); grid.ID = "test"; grid.DisplayView = WebGrid.Enums.DisplayView.Detail; BeforeGetDataExecuted = 0; grid.BeforeGetData += grid_BeforeGetData; grid.Columns["EmployeeID"].ColumnType = WebGrid.Enums.ColumnType.Number; grid.Columns["EmployeeID"].Primarykey = true; grid.Columns["FirstName"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["LastName"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["Address"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["BirthDay"].ColumnType = WebGrid.Enums.ColumnType.DateTime; grid.Columns["CustomerType"].ColumnType = WebGrid.Enums.ColumnType.Foreignkey; grid.Columns["CustomerType"].AllowEditInGrid = true; ((WebGrid.Foreignkey)grid.Columns["CustomerType"]).ValueColumn = "title"; 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.AreEqual(((Foreignkey)grid.Columns["CustomerType"]).Table.Rows.Count, 3+1);//??? Assert.AreEqual(grid.SystemMessage.Count, 0); Assert.AreEqual(BeforeGetDataExecuted, 1); }
public void LoadGridWithNeedDataGridView() { NorthwindEmployeeData employeedata = new NorthwindEmployeeData(); List<NorthwindEmployee> employees = employeedata.GetAllEmployeesList("", 0, 100); Grid grid = new Grid(); grid.DataBind(); grid.ID = "test"; BeforeGetDataExecuted = 0; grid.BeforeGetData += grid_BeforeGetData; grid.Columns["EmployeeID"].ColumnType = WebGrid.Enums.ColumnType.Number; grid.Columns["EmployeeID"].Primarykey = true; grid.Columns["FirstName"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["LastName"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["Address"].ColumnType = WebGrid.Enums.ColumnType.Text; grid.Columns["BirthDay"].ColumnType = WebGrid.Enums.ColumnType.DateTime; grid.Columns["CustomerType"].ColumnType = WebGrid.Enums.ColumnType.Foreignkey; grid.Columns["CustomerType"].AllowEditInGrid = true; grid.Columns["CustomerType2"].ColumnType = WebGrid.Enums.ColumnType.Foreignkey; grid.Columns["CustomerType2"].AllowEditInGrid = true; ((WebGrid.Foreignkey)grid.Columns["CustomerType"]).ValueColumn = "title"; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter gridwriter = new HtmlTextWriter(sw); grid.RenderControl(gridwriter); Assert.AreEqual(BeforeGetDataExecuted, 1); Assert.AreEqual(grid.MasterTable.Rows.Count, employees.Count); Assert.AreEqual( ((WebGrid.Foreignkey)grid.Columns["CustomerType"]).Table.Rows.Count, 3); Assert.AreEqual(((WebGrid.Foreignkey)grid.Columns["CustomerType2"]).Table.Rows.Count, 9); Assert.AreEqual(grid.SystemMessage.Count, 0); }
public void LoadGridWithEmployeesGenericList() { NorthwindEmployeeData employeedata = new NorthwindEmployeeData(); List<NorthwindEmployee> employees = employeedata.GetAllEmployeesList("", 0, 100); Grid grid = new Grid(); grid.DataSource = employees; grid.DataBind(); 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); }