<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RowCellEditing.aspx.cs" Inherits="DataGrid_RowCellEditing" %>
<%@ Register TagPrefix="APNSoft" Namespace="APNSoft.WebControls" Assembly="APNSoftControls" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    
    <script type="text/javascript">

    function CheckCellValue(GridID, RowID, ColumnName, CellValue){
        
        //Unescape Cell Value
        var CellValueUnescaped=unescape(CellValue);
        
        //Validation
        if(CellValueUnescaped == ''){

            //If the value is not correct, procedure should return error message (is displayed as alert) or false.
            return ColumnName + ' cannot be empty!';
        };
        
        
        //Auto-correction
        if(ColumnName == 'ContactName'){

            //Capitalize first letters
            var CellValueCorrected = CellValueUnescaped.replace(/(^|\s)([a-z])/g, function(m,p1,p2){return p1+p2.toUpperCase();});

            //Set corrected value
            dg.CellValue = CellValueCorrected;
        };
        
        //No errors found
        return true;
    };
    
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <APNSoft:APNSoftDataGrid id="myDataGrid" runat="server"
        SkinFolder = "~/DataGrid/Skins/GrayScale/"
        width = "550" 
        height = "250" 
        CellEditingEnabled = "true"
        ClientSideBeforeCellUpdate = "CheckCellValue('$ComponentID$', '$RowID$', '$ColumnName$', '$CellValue$');"
    />






    </div>
    </form>
</body>
</html>