This works for me
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox txt = (TextBox)e.Row.FindControl("txt");
txt.Attributes.Add("onclick", "f1()");
}
}
I just write a simple javascript to alert hello in that f1()
<script type="text/javascript">
function f1() {
alert('Hello');
}
</script>
alternative you can pass the control to function if needed