Hi
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var datatable = GetGridDT();
var emp = (from DataRow row in datatable.Rows
select new OrderTable
{
OrderID = Convert.ToInt32(row["OrderID"]),
CustomerID = row["CustomerID"].ToString(),
EmployeeID = Convert.ToInt32(row["EmployeeID"]),
ShipCountry = row["ShipCountry"].ToString()
}).ToList();
this.FlatGrid.DataSource = emp;
}
public static DataTable GetGridDT()
{
var connection = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString;
var dataTable = new DataTable();
using (var dataAdapter = new SqlDataAdapter("SELECT * from Orders", connection))
{
dataAdapter.Fill(dataTable);
}
return dataTable;
}
|
protected void Page_Load(object sender, EventArgs e)
{
var datatable = GetGridDT();
var rows = Utils.DataTableToJson(datatable);
this.FlatGrid.DataSource = rows;
}
|