tags:

views:

1430

answers:

1
    private void CheckBox_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chk = (CheckBox)sender;
        SetValuesInDB( System.Security.Principal.WindowsIdentity.GetCurrent().Name,
                       DateTime.Today.Date);

    }

Now I want to setvalues of my id and current date in database only if I directly clicked on the checkbox.

I dont want to update those values in Database if some other event triggers this event handler. For eg: while loading everytime the checkbox gets checked but the database value for this checkbox is unchecked. so, everytime this event handler is triggered and database value is updated. How do I take care of it?

+2  A: 

Use the CheckBox.Click event instead. It gets fired if either the user clicks on the checkbox or uses Space to toggle the checkbox.

foson