ADO Net Database ASP.Net Tutorial

The GridView, DetailsView, and FormView controls all include events that expose the 
Exception and ExceptionHandled properties.
<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    protected void grdProducts_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
        if (e.Exception != null)
        {
            lblError.Text = e.Exception.Message;
            e.ExceptionHandled = true;
        }
    }



    
    

            id="lblError"
        EnableViewState="false"
        CssClass="error"
        Runat="server" />
            id="grdProducts"
        DataKeyNames="Id"
        AutoGenerateEditButton="true"
        DataSourceID="srcProducts"
        OnRowUpdated="grdProducts_RowUpdated"
        Runat="server" />
            id="srcProducts"
        SelectCommand="SELECT Id,Title FROM Products"
        UpdateCommand="UPDATE DontExist SET Title=@Title WHERE Id=@ID"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        Runat="server" />
    

    


File: Web.config

  
             connectionString="Data Source=.\SQLEXPRESS;
         AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True" />