Asp.Net GridView How to Check row in Gridview From Javascript

To check There Row in GridView From Javascript ]

Bind Grid View From dataSource and Take its rowcount in HiddenField

Take One HiddenField and Assign Gridview RowCount in That HiddenField

dgApprvOfficer.DataSource = dt;
dgApprvOfficer.DataBind();
HiddenField1.Value = dgApprvOfficer.Rows.Count.ToString();

function validate()
{

if (document.getElementById(“<%=HiddenField1.ClientID%>”).value == “” || document.getElementById(“<%=HiddenField1.ClientID%>”).value == “0”)
{
alert(“Please Enter Roe in Grid “);
return false;
}
}

Call Javascript Function From Code Behind

btnSave.Attributes.Add(“onclick”, “return validate()”);

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