當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。