0
votes

I wanted to know which is the right event to choose for making changes according to DataGridView checkbox cell value.

I want to do "A" when the checkbox is Checked and "B" when it's unchecked.

I've used CurrentCellDirtyStateChanged event and it worked partially. if i'm changing the value and then staying in the cell and change it again it causes unwanted behaviour(calling the cellclick event).

how can i prevent it?

1
From msdn: To commit the change when the cell is clicked, you must handle the DataGridView.CurrentCellDirtyStateChanged event. In the handler, if the current cell is a check box cell, call the DataGridView.CommitEdit method and pass in the Commit value. Are you calling the Commit edit and passing the Commit value?CodingYoshi
I read it already but i don't know how to use it with my code.Kfir
I don't know how to use it with your code either because I dont have your code... Edit your question and add your code. Also add tags to indicate you are using windows forms so people don't suggest web solutions etc.CodingYoshi

1 Answers

1
votes

Try this:

<asp:TemplateField HeaderText="View">
   <ItemTemplate>
      <asp:CheckBox ID="chkview" runat="server" AutoPostBack="true" OnCheckedChanged="chkview_CheckedChanged" />
   </ItemTemplate>
</asp:TemplateField>

and in the .cs page,

protected void chkview_CheckedChanged(object sender, EventArgs e)
{
    //Handle desired behavior 

}