protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
	{
		GridEditFormItem editForm = (GridEditFormItem)e.Item;
		Hashtable newValues = new Hashtable();
		XMLContext context = new XMLContext();
		XDocument document = context.LoadDocument(GetPath());
		List<XElement> ordersTable = context.GetTable(document, "Orders").ToList();
		//Extract the new values from the editor controls
		editForm.ExtractValues(newValues);

		//Get the "Primary key" value that will be used to perform CRUD operations
		string orderID = editForm.GetDataKeyValue(RadGrid1.MasterTableView.DataKeyNames[0]).ToString();
		//Get a reference to the modified record
		XElement orderToUpdate = (from order in ordersTable
								  where order.Attribute("OrderID").Value == orderID
								  select order).FirstOrDefault();

		context.UpdateElement(ordersTable, ApplyChanges(orderToUpdate, newValues));
		context.SaveChanges(document, GetPath());
		;
	}
	protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
	{
		GridDataItem editForm = (GridDataItem)e.Item;
		XMLContext context = new XMLContext();
		XDocument document = context.LoadDocument(GetPath());
		List<XElement> ordersTable = context.GetTable(document, "Orders").ToList();
		string orderID = editForm.GetDataKeyValue(RadGrid1.MasterTableView.DataKeyNames[0]).ToString();

		XElement orderToDelete = (from order in ordersTable
								  where order.Attribute("OrderID").Value == orderID
								  select order).FirstOrDefault();
		context.DeleteElement(ordersTable, orderToDelete);
		context.SaveChanges(document, GetPath());

	}
	protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
	{
		XMLContext context = new XMLContext();
		XDocument document = context.LoadDocument(GetPath());
		List<XElement> ordersTable = context.GetTable(document, "Orders").ToList();
		//RadGrid1.VirtualItemCount = ordersTable.Count();
		var gridSource = (from order in ordersTable
						  select new
						  {
							  OrderID = order.Attribute("OrderID").Value,
							  CustomerID = order.Element("CustomerID").Value,
							  OrderDate = order.Element("OrderDate").Value,
							  Freight = order.Element("Freight").Value,
							  ShipName = order.Element("ShipName").Value,
							  ShipCity = order.Element("ShipCity").Value,
							  ShipCountry = order.Element("ShipCountry").Value
						  });
		RadGrid1.DataSource = gridSource.Skip(RadGrid1.CurrentPageIndex).Take(RadGrid1.PageSize);

	}
	protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
	{
		GridEditFormItem editForm = (GridEditFormItem)e.Item;
		Hashtable newValues = new Hashtable();
		XMLContext context = new XMLContext();
		XDocument document = context.LoadDocument(GetPath());
		List<XElement> ordersTable = context.GetTable(document, "Orders").ToList();
		//Extract the new values from the editor controls
		editForm.ExtractValues(newValues);
		XElement orderToInsert = new XElement("Order");
		int orderID = int.Parse((from order in ordersTable
								 select order).LastOrDefault().Attribute("OrderID").Value);
		orderToInsert.Add(new XAttribute("OrderID", ++orderID));
		context.InsertElement(document, ApplyChanges(orderToInsert, newValues), "Orders");
		context.SaveChanges(document, GetPath());

	}