Daron_1 0 AntonioMicheal
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="XEx14ProductReceipt.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ch14: Product Receipt</title>

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link href="Content/bootstrap.min.css" rel="stylesheet" />

    <link href="Content/site.css" rel="stylesheet" />
    <script src="Scripts/jquery-1.9.1.min.js"></script>

    <script src="Scripts/bootstrap.min.js"></script>
</head>

<body>
<div class="container">
    <header class="jumbotron"><%-- image set in site.css --%></header>
    <main>
        <form id="form1" runat="server" class="form-horizontal">
            <div class="row">
                <div class="col-xs-12">
                    <asp:GridView ID="grdProducts" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1" 
                        CssClass="table table-bordered table-condensed">
                        <Columns>
                            <asp:BoundField DataField="ProductID" HeaderText="ID" SortExpression="ProductID"
                                ReadOnly="True">
                                <HeaderStyle CssClass="col-sm-2" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ReadOnly="true">
                                <HeaderStyle CssClass="col-sm-6" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="On Hand">
                            <EditItemTemplate>
                                <div class="padding-adjust">
                                   <asp:TextBox ID="txtGridOnHand" runat="server" CssClass="form-control" Text='<%# Bind("OnHand") %>'></asp:TextBox>
                                 </div>
                               <asp:RequiredFieldValidator ID="rfvOnHand" runat="server" ErrorMessage="Required Entry" CssClass="text-danger" ControlToValidate="txtGridOnHand" Text="*"> </asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="cvOnHand" runat="server" ControlToValidate="txtGridOnHand" CssClass="text-danger" Operator="GreaterThanEqual" ValueToCompare="0" ErrorMessage="Integer must be greater or equal to zero" Text="*"> </asp:CompareValidator>
                            </EditItemTemplate>   
                                 <ItemTemplate>
                                    <asp:Label ID="lblGridOnHand" runat="server" Text='<%# Bind("OnHand") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowEditButton="true">
                            </asp:CommandField>
                        </Columns>
                        <HeaderStyle CssClass="bg-halloween" />
                        <AlternatingRowStyle CssClass="altRow" />
                        <EditRowStyle CssClass="warning" />
                        <PagerStyle CssClass="bg-halloween" HorizontalAlign="Center" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:HalloweenConnection %>" 
                        SelectCommand="SELECT ProductID, Name, OnHand FROM Products" 
                        UpdateCommand="UPDATE Products SET OnHand = @OnHand WHERE (ProductID = @ProductID)">
                        <UpdateParameters>
                            <asp:Parameter Name="OnHand" />
                            <asp:Parameter Name="ProductID" />
                        </UpdateParameters>
                    </asp:SqlDataSource>    
                </div>  
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <p><asp:Label ID="lblError" runat="server"  
                        CssClass="text-danger" EnableViewState="false"></asp:Label></p>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                        HeaderText="Please correct the following errors:" CssClass="text-danger" />
                </div>
            </div>
        </form>
    </main>
</div>
</body>
</html>

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

namespace XEx14ProductReceipt
{
    public partial class Default : System.Web.UI.Page
    {
        protected void grdProducts_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            if (e.Exception != null)
            {
                lblError.Text = "A database error has occured.";
                e.ExceptionHandled = true;

            }

        }
    }
}

I am not sure how I can exactly display the database error message without it interfering with the Requiredfieldvalidator I know that I can turn off the requiredfieldvalidator, but I want them both to be able to work within my application. It's useless to have created a database error event handler if it will never be able to display the message in lblError inside of the GridView control just because the RequiredFieldValidator conflict with it. Can someone please help me? Here is my code below: