本文整理汇总了C#中WebGrid.Grid类的典型用法代码示例。如果您正苦于以下问题:C# Grid类的具体用法?C# Grid怎么用?C# Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Grid类属于WebGrid命名空间,在下文中一共展示了Grid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}