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?
Satyapriya NayakPosted Oct 15, 2012, 9:47 AM
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
Nitesh KejriwalPosted Oct 15, 2012, 9:16 AM
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
Kunal VaishyaPosted Oct 15, 2012, 8:39 AM
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