I would suggest you to handle it at client-side instead. You could easily do that with jQuery. Here's a quick example:
HTML:
<asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtCommission" placeholder="Enter value" runat="server" CssClass="txtField" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblCommission" runat="server" CssClass="lblField" Text='<%# Bind("Commission") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
jQuery Reference:
<script src="https://code.jquery.com/jquery-3.1.0.slim.min.js" integrity="sha256-cRpWjoSOw5KcyIOaZNo4i6fZ9tKPhYYb6i5T9RSVJG8=" crossorigin="anonymous"></script>
JavaScript:
$(function () {
$(".txtField").keyup(checkValue);
function checkValue() {
$(".txtField").each(function () {
var $val1 = parseInt($(this).val()) || 0;
var $val2 = parseInt($(this).parent().parent().find(".lblField").text()) || 0;
if ($val1 > $val2) {
alert("Please enter a value less than the commission");
$(this).focus();
return false;
}
});
}
});
CODE BEHIND:
using System;
using System.Collections.Generic;
namespace WebFormsDemo
{
public class Item
{
public string Name { get; set; }
public int Commission { get; set; }
}
public partial class JavaScript : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<Item> item = new List<Item>();
item.Add(new Item { Name = "Item1", Commission = 100 });
item.Add(new Item { Name = "Item2", Commission = 200 });
item.Add(new Item { Name = "Item3", Commission = 300 });
item.Add(new Item { Name = "Item4", Commission = 400 });
item.Add(new Item { Name = "Item5", Commission = 500 });
gv1.DataSource = item;
gv1.DataBind();
}
}
}
}
That should work based on your requirements.