Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I added 3 check box columns in the datagridview .if i clicked the checkbox it not to be checked?
if i click the checkbox it want to be checked.but not able to get checkbox to be checked

how to solve the problem
Posted

XML
<ItemTemplate><asp:CheckBox ID="CheckBox1" runat="server"
                            oncheckedchanged="CheckBox1_CheckedChanged" /></ItemTemplate>
 
Share this answer
 
in desktop add event for datagridview
C#
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1)
{
	if (DataGridView1.Rows[e.RowIndex].Cells[1].Value == null || DataGridView1.Rows[e.RowIndex].Cells[1].Value == DBNull.Value || Convert.ToBoolean(DataGridView1.Rows[e.RowIndex].Cells[1].Value) == false)
	{
  	   DataGridView1.Rows[e.RowIndex].Cells[1].Value = true;
	}
 }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900