本文整理汇总了C#中WebGrid.Grid.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.RenderControl方法的具体用法?C# Grid.RenderControl怎么用?C# Grid.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGrid.Grid
的用法示例。
在下文中一共展示了Grid.RenderControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: LoadGridWithEmployeesGenericDictionary
public void LoadGridWithEmployeesGenericDictionary()
{
NorthwindEmployeeData employeedata = new NorthwindEmployeeData();
Dictionary<int,NorthwindEmployee> employees = employeedata.GetAllEmployeesDictionary("", 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);
}
示例12: 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);
}
示例13: 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.GotDataSourceCache);
}
示例14: CreateAndDeleteRecord
public void CreateAndDeleteRecord()
{
CreateRecordSelect();
int CategoryId = GetCategoryId();
Grid grid = new Grid();
Testpage.Controls.Add(grid);
SetDataSource(grid);
grid.ID = "test";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.Standard;
grid.Width = Unit.Pixel(1000);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
Assert.AreEqual(grid.MasterTable.DataSourceType, DataSourceControlType.AccessDataSource);
int records = grid.MasterTable.Rows.Count;
grid = new Grid();
Testpage.Controls.Add(grid);
SetDataSource(grid);
grid.ID = "test";
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.Standard;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent(string.Format("RecordDeleteClick!{0}", CategoryId));
sb = new StringBuilder();
sw = new StringWriter(sb);
gridwriter = new HtmlTextWriter(sw);
////grid.ReLoadData = true;
grid.RenderControl(gridwriter);
// Assert.AreEqual(grid.MasterTable.Rows.Count, GetCategoryCount());
// Assert.AreEqual(records-1, grid.MasterTable.Rows.Count);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
Assert.LessOrEqual(grid.SystemMessage.Count, 1);
}
示例15: CreateAndDeleteRecord
public void CreateAndDeleteRecord()
{
CreateRecord();
string CategoryId =
Query.ExecuteScalar("SELECT TOP 1 CategoryID FROM Categories ORDER BY CategoryID DESC",
ConnectionAccessOleDb).ToString();
Grid grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
grid.RenderControl(gridwriter);
int records = grid.MasterTable.Rows.Count;
grid = new Grid();
grid.DataSourceId = "Categories";
grid.ID = "test";
grid.ConnectionString = ConnectionAccessOleDb;
grid.DefaultVisibility = Visibility.Both;
grid.RecordsPerRow = 2;
grid.PagerSettings.PagerType = PagerType.None;
grid.Width = Unit.Pixel(1000);
grid.RaisePostBackEvent("RecordDeleteClick!" + CategoryId);
sb = new StringBuilder();
sw = new StringWriter(sb);
gridwriter = new HtmlTextWriter(sw);
grid.MasterTable.GetData(true);
grid.RenderControl(gridwriter);
// Assert.Less(grid.MasterTable.Rows.Count, records);
Assert.AreEqual(grid.DisplayView, DisplayView.Grid);
}