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

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

    }
    protected void btnAtualizar_Click(object sender, EventArgs e)
    {
        using (NorthwindDataContext db = new NorthwindDataContext())
        {
            var categorias = from c in db.Categories
                             where c.CategoryID > 8
                             select c;

            foreach (var item in categorias)
            {
                item.CategoryName = "Novo nome";
                item.Description = "Nova descrição";
            }
            
            try
            {
                db.SubmitChanges();
                Preencher();
            }
            catch (Exception)
            {
                //Mensagem de erro aqui;
            }
        }
    }

    void Preencher()
    {
        using (NorthwindDataContext db = new NorthwindDataContext())
        {
            var categoria = from c in db.Categories
                            select c;

            GridView1.DataSource = categoria;
            GridView1.DataBind();
        }
    }
}