using System;
using System.Linq;
using System.Web.UI.WebControls;

public partial class SelectSimples : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void btnExecutar_Click(object sender, EventArgs e)
    {
        using (NorthwindDataContext db = new NorthwindDataContext())
        {
            var produtos = from p in db.Products
                           where p.CategoryID == 1 //&& p.ProductName == "Chai"
                           select new { p.CategoryID, p.ProductID, p.ProductName, p.UnitPrice };

            GridView1.DataSource = produtos;
            GridView1.DataBind();
            
            /*foreach (var item in produtos)
            {
                Response.Write(item.CategoryID + " --- ");
                Response.Write(item.ProductID + " --- ");
                Response.Write(item.ProductName + " --- ");
                Response.Write(String.Format("{0:c}", Convert.ToDecimal(item.UnitPrice)) + "<br/>");
            }*/            
        }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[3].Text = String.Format("{0:c}", Convert.ToDecimal(e.Row.Cells[3].Text));
        }
    }
}