Hi team,
can someone help me on how i should check or uncheck checkbox in c# using asp.net.
Regard
George
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 16, 2012, 11:33 PM
You can do it like this.
bool isCheck = false;
if(chkHeader.Checked)
{
isCheck = true;
}
for(int i=0;i
GridViewRow gv = gridview1.Rows[0];
CheckBox chk = (CheckBox) gv.FindControl("chkRow");
if(isCheck)
{
chk.Checked = true;
}
else
{
chk.Checked = false;
}
}
Hope this will help you how to do it in server side.
Satyapriya NayakPosted Apr 16, 2012, 1:38 AM
Select Deselect all checkbox in gridview
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Default.aspx.vb code
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con As New SqlConnection(strConnString)
Dim str As String
Dim com As SqlCommand
Dim sqlda As SqlDataAdapter
Dim ds As DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con.Open()
str = "select * from student"
com = New SqlCommand(Str, con)
Dim reader As SqlDataReader
reader = com.ExecuteReader()
GridView1.DataSource = reader
GridView1.DataBind()
con.Close()
End Sub
End Class
Also refer
http://www.c-sharpcorner.com/uploadfile/krishnasarala/checkuncheck-all-checkboxes-in-Asp-Net-gridview/default.aspx
Thanks
If this post helps you mark it as answer
Sean StewartPosted Apr 16, 2012, 1:07 AM