check all checkbox in gridview using javascript

.aspx page

    function Check(pcheck)
   var a = document.getElementsByTagName("input");
   if(pcheck.checked == true)
   if(a[i].type == 'checkbox')
   a[i].checked = true;
   a[i].checked = false;


.CS page

protected void Page_Load(object sender, EventArgs e)
        DataTable dt = new DataTable();
        dt.Columns.Add("EmpCode", typeof(int));
        dt.Columns.Add("EmpName", typeof(string));
        dt.Rows.Add(1, "a");
        dt.Rows.Add(2, "b");
        GridView1.DataSource = dt;

This entry was posted in Asp.Net. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s