Hi as an Example..
I have this text field in the gridview ....
<asp:TemplateField HeaderText="Text Column">
<ItemTemplate>
<asp:TextBox ID="Text" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
On the griview I am defining a eventhandler for row databound event like this....(OnRowDataBound="GridView1_RowDataBound")
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="ProductId" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound">
on the code behind RowDataBound code like this...
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
TextBox textbox = (TextBox)e.Row.Cells[4].FindControl("Text");
textbox.Attributes.Add("onblur", "validateText(this)");
}
}
In the master page header I have the javascript like ....
<script type="text/javascript">
function validateText(textbox) {
alert("You entered " + textbox.value);
}
</script>
Now it can execute the validate script onblur....you can attach this script to another cells in the gridview too.
Hope this helps