本文整理汇总了C#中WebGrid.Grid类的典型用法代码示例。如果您正苦于以下问题:C# Grid类的具体用法?C# Grid怎么用?C# Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Grid类属于WebGrid命名空间,在下文中一共展示了Grid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RenderGridWithRows
public void RenderGridWithRows()
{
Grid grid = new Grid();
grid.ID = "test";
Row newrow = new Row( grid.MasterTable);
newrow["title"].Value = "title 1";
newrow["Description"].Value = @"description 1";
newrow["sampleurl"].Value = "sample url 1";
newrow["PrimaryColumn"].Value = "1";
grid.AddRow(newrow);
newrow = new Row( grid.MasterTable);
newrow["title"].Value = "title 2";
newrow["Description"].Value = @"description 2";
newrow["sampleurl"].Value = "sample url 2";
newrow["PrimaryColumn"].Value = "2";
grid.AddRow(newrow);
newrow = new Row( grid.MasterTable);
newrow["title"].Value = "title 3";
newrow["Description"].Value = @"description 3";
newrow["sampleurl"].Value = "sample url 3";
newrow["PrimaryColumn"].Value = "3";
grid.AddRow(newrow);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:32,代码来源:Rendering.cs
示例2: GetEmployeesAccessMasterGrid
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:35,代码来源:Relations.cs
示例3: CheckboxColumn
public void CheckboxColumn()
{
Grid grid = new Grid();
Checkbox column = new Checkbox("column", grid.MasterTable);
column.Required = true;
column.Primarykey = true;
Checkbox column2 = new Checkbox("column2", grid.MasterTable);
Checkbox column3 = new Checkbox("column3", grid.MasterTable);
Checkbox column4 = new Checkbox("column4", grid.MasterTable);
grid.MasterTable.Columns.Add(column);
grid.MasterTable.Columns.Add(column2);
grid.MasterTable.Columns.Add(column3);
grid.MasterTable.Columns.Add(column4);
SetupGrid(grid);
// Not allowed content
grid.MasterTable.Rows[0]["column"].Value = "1";
grid.MasterTable.Rows[0]["column2"].Value = "sdf30";
grid.MasterTable.Rows[0]["column3"].Value = "TRUE";
grid.MasterTable.Rows[0]["column4"].Value = "";
Assert.AreEqual(grid.DisplayView, DisplayView.Detail);
grid.RaisePostBackEvent("RecordUpdateClick!!False");
Assert.AreEqual(grid.SystemMessage.Count, 0);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:28,代码来源:ColumnPostBackClick.cs
示例4: GetEmployeesAccessMasterGridEdit
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:33,代码来源:Relations.cs
示例5: GridRowBoundAllowEditInRow
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);
}
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:60,代码来源:ColumnValue.cs
示例6: RenderEmptyGrid
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:10,代码来源:Rendering.cs
示例7: SqlServerGrouping
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:11,代码来源:Grouping.cs
示例8: SetupSqlServerGrid
private void SetupSqlServerGrid(Grid grid)
{
grid.ID = "wggrid";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.DataSourceId = "Order Details";
grid.ConnectionString = ConnectionSqlConnection;
Testpage.Controls.Add(grid);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:12,代码来源:Grouping.cs
示例9: SetupAccessGrid
private void SetupAccessGrid(Grid grid)
{
grid.ID = "wggrid";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.DataSourceId = "Customers";
grid.ConnectionString = ConnectionAccessOleDb;
Testpage.Controls.Add(grid);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:12,代码来源:Grouping.cs
示例10: GetEmployeesErrorWhere
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:12,代码来源:Exception.cs
示例11: GetUnknownDataSource
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:12,代码来源:Exception.cs
示例12: GridRowBound
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:12,代码来源:ColumnValue.cs
示例13: GetAccessOleDBAllowEditInGridTrue
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:13,代码来源:Properties.cs
示例14: GetAccessOleDb
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:13,代码来源:DataSource.cs
示例15: GetEmployeesAccessInvalidMasterGrid
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:13,代码来源:Exception.cs
示例16: GetAccessOleDBAllowEditInGridTFalse
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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:15,代码来源:Properties.cs
示例17: LoadGridWithEmployeesGenericList
public void LoadGridWithEmployeesGenericList()
{
NorthwindEmployeeData employeedata = new NorthwindEmployeeData();
List<NorthwindEmployee> employees = employeedata.GetAllEmployeesList("", 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);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:15,代码来源:DataSourceGeneric.cs
示例18: GetAccessOleDbCacheIsFalse
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.GotCache);
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:16,代码来源:DataSource.cs
示例19: GetAccessOleDbCacheIsTrue
public void GetAccessOleDbCacheIsTrue()
{
Grid grid = new Grid();
grid.Sql = "SELECT * FROM Employees";
grid.ID = "test";
grid.Page = Testpage;
grid.CacheGridStructure = true;
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.IsTrue(grid.MasterTable.CacheDatasourceStructure);
// Assert.IsTrue(grid.MasterTable.GotDataSourceCache); // HttpRuntime.Cache is needed to actually store the data source.
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:16,代码来源:DataSource.cs
示例20: GetAccessOleDb
public void GetAccessOleDb()
{
Grid grid = new Grid();
grid.Sql = "SELECT * FROM Employees";
grid.ID = "test";
grid.Page = Testpage;
grid.PageLength = 2;
grid.ConnectionString = ConnectionAccessOleDb;
WebGrid.GridPart part1 = new WebGrid.GridPart();
part1.Page = Testpage;
part1.MasterGrid = grid.ID;
part1.GridPartType = WebGrid.Enums.GridPart.NewRecord;
part1.ID = "part1";
part1.Html = "New Record Button";
Testpage.Controls.Add(part1);
WebGrid.GridPart part2 = new WebGrid.GridPart();
part1.Page = Testpage;
part1.MasterGrid = grid.ID;
part1.GridPartType = WebGrid.Enums.GridPart.Pager;
part1.ID = "part2";
Testpage.Controls.Add(part2);
WebGrid.GridPart part3 = new WebGrid.GridPart();
part1.Page = Testpage;
part1.MasterGrid = grid.ID;
part1.GridPartType = WebGrid.Enums.GridPart.SearchField;
part1.ID = "part3";
Testpage.Controls.Add(part3);
WebGrid.GridPart part4 = new WebGrid.GridPart();
part1.Page = Testpage;
part1.MasterGrid = grid.ID;
part1.GridPartType = WebGrid.Enums.GridPart.UpdateRecords;
part1.ID = "part4";
Testpage.Controls.Add(part4);
Testpage.Controls.Add(grid);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
Testpage.RenderControl(gridwriter);
Console.WriteLine(sb.ToString());
}
开发者ID:webgrid,项目名称:WebGrid,代码行数:46,代码来源:GridPart.cs
注:本文中的WebGrid.Grid类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论