Update needsource snippet with a shorter version
This commit is contained in:
Родитель
9a575101eb
Коммит
1c90c081ca
|
@ -15,43 +15,27 @@
|
|||
<Code Language="csharp">
|
||||
<![CDATA[ protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
|
||||
{
|
||||
(sender as RadGrid).DataSource = GetGridSource(); $end$
|
||||
(sender as RadGrid).DataSource = GetGridSource();
|
||||
}
|
||||
|
||||
private DataTable GetGridSource()
|
||||
{
|
||||
DataTable dataTable = new DataTable();
|
||||
|
||||
DataColumn column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.Int32");
|
||||
column.ColumnName = "OrderID";
|
||||
dataTable.Columns.Add(column);
|
||||
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)));
|
||||
|
||||
column = new DataColumn();
|
||||
column.DataType = Type.GetType("System.DateTime");
|
||||
column.ColumnName = "OrderDate";
|
||||
dataTable.Columns.Add(column);
|
||||
dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns["OrderID"] };
|
||||
|
||||
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++)
|
||||
for (int i = 0; i < 70; i++)
|
||||
{
|
||||
// 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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче