当前位置: 首页>>代码示例>>C#>>正文


C# Grid.DataBind方法代码示例

本文整理汇总了C#中WebGrid.Grid.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.DataBind方法的具体用法?C# Grid.DataBind怎么用?C# Grid.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebGrid.Grid的用法示例。


在下文中一共展示了Grid.DataBind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadGridWithNeedDataDetailView

 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);
 }
开发者ID:webgrid,项目名称:WebGrid,代码行数:26,代码来源:DataSourceGeneric.cs

示例2: LoadGridWithNeedDataGridView

        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);
        }
开发者ID:webgrid,项目名称:WebGrid,代码行数:31,代码来源:DataSourceGeneric.cs

示例3: LoadGridWithEmployeesGenericList

        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);
        }
开发者ID:webgrid,项目名称:WebGrid,代码行数:16,代码来源:DataSourceGeneric.cs


注:本文中的WebGrid.Grid.DataBind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。