ASP.NET - How to fire textbox changed event of inside gridview textbox

Asked By bhanupratap singh on 03-Oct-12 12:39 PM
I have gridview in item template I want to check data into table when user leave txtCnmt.Text which in inside of my gridview
On txtCnmt.text changed event i want to search data from table to veryfiy whether data exsit into table or not
thanks
Robbe Morris replied to bhanupratap singh on 03-Oct-12 01:06 PM
Wire up the event in your ItemTemplate TextBox control. 

<ItemTemplate >
   <asp:TextBox ID ="MyTextBox" runat ="server" onTextChanged="OnMyTextBoxChangedEvent"/>
</ItemTemplate>

Then, put this in your code behind:


public void OnMyTextBoxChangedEvent(object sender,EventArgs e)
{
   var textBox = (sender as TextBox);
}
Ravichandran K replied to Robbe Morris on 03-Oct-12 11:38 PM
use jquery library...

< ItemTemplate >
<asp:TextBox ID ="MyTextBox" runat ="server" onblur="CheckDuplicate(this)" ClassCss="finderCell"/>
< /ItemTemplate>


<script>
function CheckDuplicate(control)
{
var currentValue = $("#"+control).val();
var isDuplicate= false;
$.each(".finderCell", function(index,value){
if(value== currentValue){
isDuplicate = true;
}
});

if(isDuplicate){
alert("the entered value is exists!!!");
}
}
</script>

try the above....