This is a migrated thread and some comments may be shown as answers.

ValueChanging not fired

1 Answer 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 12 Jan 2015, 07:04 PM
I have a radGridView (2014.2.715.40) component having among others 2 checkbox columns.  One is named "IsConcilie" and the other one is "IsRetenu".  For each row, when 1 of these columns is true, we can't set the other one to true.  Only one of these 2 columns may be true at a time.  If the user tries to put the second to true, he is advised.  The radGridView is named "MasterTemplate".

Because I want to be able to cancel the action, I added this event handler:
this.MasterTemplate.ValueChanging += new ValueChangingEventHandler(MasterTemplate_ValueChanging);

Then I coded the following:

void MasterTemplate_ValueChanging(object sender, ValueChangingEventArgs e)
{
    GridDataCellElement ce = this.MasterTemplate.CurrentCell;
    if (ce.Name == "IsConcilie")
    {
           if (e.NewValue.Equals(false)) return;
           if (this.MasterTemplate.CurrentRow.Cells["IsRetenu"].Equals(true))
           {
                MessageBox.Show( "You cannot verify a retained cheque", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                e.Cancel = true;
            }
     }
     if (ce.Name == "IsRetenu")
     {
          if (e.NewValue.Equals(false)) return;
          if (this.MasterTemplate.CurrentRow.Cells["IsConcilie"].Equals(true))
          {
               MessageBox.Show("You cannot retain a verified cheque", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
               e.Cancel = true;
           }
      }
}

Unfortunately, whenever we click one of these checkboxes, the event is not fired.  What's wrong?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Jan 2015, 11:21 AM
Hello Claude,

Thank you for writing.

When I set up the RadGridView to contain GridViewCheckBoxColumns, the ValueChanging event is fired as expected on my end. However, I slightly modified the provided code snippet. It is necessary to check the GridDataCellElement.ColumnInfo.Name instead of the name of the cell itself. Additionally, in order to determine whether the other check box cell is checked or not, you should access the CurrentRow.Cells["your column name"].Value property. Please refer to the attached gif file. I have attached my sample project as well.

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or