Copies the elements of the specified WebGridCell array to the end of the collection.
Syntax
Visual Basic (Declaration) | |
---|
Public Overridable Sub AddRange( _
ByVal cells() As WebGridCell _
) |
Parameters
- cells
Example
The sample codes below show that you can create several cells and rows in one line of code, and add them at once using AddRange method of the collection. CreateRow is a new method of WebGridTable class which creates and initializes WebGridCell according to the columns and structures available in WebGridTable. The SetItemData method allows you to easily set an array of string which will be mapped to the cells in WebGridCellCollection respectively. The AddRange method finally perform the addition of the WebGridRow arrays to the WebGridTable.
C# | Copy Code |
---|
WebGridRow[] rootRows = new WebGridRow[6];
for (int i = 0; i < 6; i++)
{
rootRows[i] = WebGrid1.RootTable.CreateRow();
rootRows[0].Cells.SetItemData(new string[] { "172-32-1176", "White", "Johnson" });
rootRows[1].Cells.SetItemData(new string[] { "213-46-8915", "Green", "Marjorie" });
rootRows[2].Cells.SetItemData(new string[] { "238-95-7766", "Carson", "Cheryl" });
rootRows[3].Cells.SetItemData(new string[] { "267-41-2394", "O'Leary", "Michael" });
rootRows[4].Cells.SetItemData(new string[] { "274-80-9391", "Straight", "Dean" });
rootRows[5].Cells.SetItemData(new string[] { "341-22-1782", "Smith", "Meander" });
WebGrid1.RootTable.Rows.AddRange(rootRows);
} |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also