本文整理汇总了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);
}
示例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);
}
示例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);
}