Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to validate gridview cell data (for ex: rows[0][3]) using Java Script.
Please any one help me in writing java script.
Posted

Its very easy

on page load write this
C#
foreach (GridViewRow row in GridView1.Rows)
{
               Button bk = (Button)row.FindControl("Button2");
               bk.Attributes.Add("onclick", "return getmew("+row.RowIndex+")");
}


then in javascript write this
C#
function getmew(dd)
    {
     var b=document.getElementById("GridView1");
     var c=document.getElementById("TextBox1");
     var d=document.getElementById("TextBox2");
     dd=dd+1;
     c.value=document.getElementById("GridView1").rows[dd].cells[2].innerHTML;
     d.value=document.getElementById("GridView1").rows[dd].cells[3].innerHTML;
}



you can use rowdatabound also....do it in your way
good luck.........
 
Share this answer
 
v2
this[^] might help you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900