/// <summary> /// LINQ to show all cars in the data grid /// <param name="sender"></param> /// <param name="e"></param> /// </summary> protected void Page_Load(object sender, EventArgs e) { var db = new CarsDBEntities(); var query = (from car in db.CarsTables select car).ToList(); GridAll.DataSource = query; GridAll.DataBind(); }
/// <summary> /// Linq for black cars and in the datagrid /// it will show only black cars /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { CarsDBEntities db = new CarsDBEntities(); var query = (from car in db.CarsTables where car.color == "Black" select car).ToList(); GridBlack.DataSource = query; GridBlack.DataBind(); }