Below is my function which insert textbox value into grid view .this work fine .
Now I want to compare grid view row with textbox value if already exist in grid view then it give me massage already exist with same name means duplicate data cannot insert into grid view. please help me I will code but can’t find the solution.
<script type="text/javascript">
$(function checkuser()
{
// $(function () {
// $("[id*=btnAddRow]").click(function () {
var operator = $("[id*=txtoperator]").val();
var value1 = $("[id*= txtvalue1]").val();
var value2 = $("[id*= txtvalue2]").val();
var total = $("[id*= txttotal]").val();
if (operator != "" && value1 != "" && value2 != "" && total != "") {
row = $("[id*=data_gridview] tr:last-child").clone(true);
$("td:nth-child(2)", row).html(operator);
$("td:nth-child(3)", row).html(value1);
$("td:nth-child(4)", row).html(value2);
$("td:nth-child(5)", row).html(total);
////////piece code for check the row alredy exist/////////
if $('[id*= data_gridview]').('tr:has(td)')= $("td:nth-child(2)", row).html(operator) && $("td:nth-child(3)", row).html(value1) && $("td:nth-child(4)", row).html(value2))
{
alert("The Value already Exist ");
}
///////////////////////////////////////////////////////////////
$("[id*=data_gridview] tbody tr:first").after(row);
}
$("[id*=txtoperator]").val('');
$("[id*= txtvalue1]").val('');
$("[id*= txtvalue2]").val('');
$("[id*= txttotal]").val('');
return false;
}
};
C# Code……./////////////////////
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[4] { new DataColumn("Opertor ", typeof(string)),
new DataColumn("Value1", typeof(string)),
new DataColumn("Value2", typeof(string)),
new DataColumn("Result", typeof(string)),
dt.Rows.Add(0, "", "", "", "");
data_gridview.DataSource = dt;
trans_gridview.DataBind();
}
Please help me to solve that problem.