check all checkbox in gridview using javascript

.aspx page

       
 
    function Check(pcheck)
    {
   var a = document.getElementsByTagName("input");
   for(i=0;i<a.length;i++)
   {
   if(pcheck.checked == true)
   {
   if(a[i].type == 'checkbox')
   {
   a[i].checked = true;
   }
   }
   else
   {
   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;
        GridView1.DataBind();

    }
Advertisements
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:

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 )

Google+ photo

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

Connecting to %s