In gridview using checkbox how to select all rows and deselect all rows by clicking the checkbox in headerpart in asp.net with c#language with example and code
in gridview using checkbox how to checked all rows and unchecked all rows by clicking the checkbox in headerpart in asp.net with c#language with example and code?

Kunal VaishyaRank #990 · 2K reputationPosted Oct 15, 2012, 4:39 AM EDT
Put Check Box In header Template and Use It
1. Add Item Template Column In Gridview.
2.Add Check Box That Column in Header Template
3. you will get it you can put your code in that check box event
Nitesh KejriwalRank #253 · 9.9K reputationPosted Oct 15, 2012, 5:16 AM EDT
http://www.c-sharpcorner.com/uploadfile/krishnasarala/checkuncheck-all-checkboxes-in-Asp-Net-gridview/
http://www.c-sharpcorner.com/UploadFile/sushmita_kumari/Checkbox201112006232423PM/Checkbox2.aspx
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 15, 2012, 5:47 AM EDT
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace WebApplication5
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from student";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "student");
GridView1.DataMember = "student";
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
}
}
Thanks
If this post helps you mark it as answer