Asp.net Grid View Javascript Validation

To Add Javasvript in Gridview For  Validation
Add Javascript Code in GridView RowDatabound Event
and call tha tfunction From Code

For GridView RowDatabound Add Javascript Code

if (e.Row.RowType == DataControlRowType.DataRow)
{

TextBox txtRate = (TextBox)e.Row.FindControl(“txtRate”);
txtRate.Attributes.Add(“onblur”, “return ValidateCalculation(‘”+txtRate.ClientID+”‘)”);
}

And in Aspx Page Add Following Javascript

<script type=”text/javascript”>
function ValidateCalculation(i)
{
alert(i);
alert(document.getElementById(i).value);
document.getElementById(i).focus();
}
</script>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s