Update needsource snippet with a shorter version
This commit is contained in:
Родитель
9a575101eb
Коммит
1c90c081ca
|
@ -14,56 +14,40 @@
|
|||
<Snippet>
|
||||
<Code Language="csharp">
|
||||
<![CDATA[ protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
|
||||
{
|
||||
(sender as RadGrid).DataSource = GetGridSource();
|
||||
}
|
||||
|
||||
private DataTable GetGridSource()
|
||||
{
|
||||
DataTable dataTable = new DataTable();
|
||||
|
||||
dataTable.Columns.Add(new DataColumn("OrderID", typeof(int)));
|
||||
dataTable.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
|
||||
dataTable.Columns.Add(new DataColumn("Freight", typeof(decimal)));
|
||||
dataTable.Columns.Add(new DataColumn("ShipName", typeof(string)));
|
||||
dataTable.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
|
||||
|
||||
dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["OrderID"] };
|
||||
|
||||
for (int i = 0; i < 70; i++)
|
||||
{
|
||||
(sender as RadGrid).DataSource = GetGridSource(); $end$
|
||||
// or use the following one-liner with the following arguments
|
||||
// OrderID, OrderDate, Freight, ShipName, ShipCountry
|
||||
//dataTable.Rows.Add(i + 1, DateTime.Now, (i + 1) + (i + 1) * 0.1 + (i + 1) * 0.01, "Name " + (i + 1), "Country " + (i + 1));
|
||||
|
||||
DataRow row = dataTable.NewRow();
|
||||
row["OrderID"] = i + 1;
|
||||
row["OrderDate"] = DateTime.Now;
|
||||
row["Freight"] = (i + 1) + (i + 1) * 0.1 + (i + 1) * 0.01;
|
||||
row["ShipName"] = "Name " + (i + 1);
|
||||
row["ShipCountry"] = "Country " + (i + 1);
|
||||
|
||||
dataTable.Rows.Add(row);
|
||||
}
|
||||
private DataTable GetGridSource()
|
||||
{
|
||||
DataTable dataTable = new DataTable();
|
||||
|
||||
DataColumn column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.Int32");
|
||||
column.ColumnName = "OrderID";
|
||||
dataTable.Columns.Add(column);
|
||||
|
||||
column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.DateTime");
|
||||
column.ColumnName = "OrderDate";
|
||||
dataTable.Columns.Add(column);
|
||||
|
||||
column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.Decimal");
|
||||
column.ColumnName = "Freight";
|
||||
dataTable.Columns.Add(column);
|
||||
|
||||
column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.String");
|
||||
column.ColumnName = "ShipName";
|
||||
dataTable.Columns.Add(column);
|
||||
|
||||
column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.String");
|
||||
column.ColumnName = "ShipCountry";
|
||||
dataTable.Columns.Add(column);
|
||||
|
||||
DataColumn[] PrimaryKeyColumns = new DataColumn[1];
|
||||
PrimaryKeyColumns[0] = dataTable.Columns["OrderID"];
|
||||
dataTable.PrimaryKey = PrimaryKeyColumns;
|
||||
|
||||
for (int i = 0; i <= 80; i++)
|
||||
{
|
||||
DataRow row = dataTable.NewRow();
|
||||
row["OrderID"] = i + 1;
|
||||
row["OrderDate"] = DateTime.Now;
|
||||
row["Freight"] = (i + 1) + (i + 1) * 0.1 + (i + 1) * 0.01;
|
||||
row["ShipName"] = "Name " + (i + 1);
|
||||
row["ShipCountry"] = "Country " + (i + 1);
|
||||
|
||||
dataTable.Rows.Add(row);
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}]]>
|
||||
return dataTable;
|
||||
}]]>
|
||||
</Code>
|
||||
<Imports>
|
||||
<Import>
|
||||
|
|
Загрузка…
Ссылка в новой задаче