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

Checkbox and Click Event

2 Answers 334 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sid
Top achievements
Rank 1
Sid asked on 30 Oct 2009, 03:52 AM
I am trying to wire-up a click event to a checkbox column inside the RadGridview.  My problem is that when I handle the click event of the check box the grid has not registered the selected item yet, so I can't access the record to obtain the value from another column for the record which was checked.  Here is the click event code:

        private void CheckBox_Click(object sender, RoutedEventArgs e)  
        {  
            CheckBox chkbox = (CheckBox)sender;  
            ApplyPaymentEntity payment = new ApplyPaymentEntity();  
            payment = (ApplyPaymentEntity)this.grdPmtDetail.SelectedItem;  
 
            if (chkbox.IsChecked == true)  
            {  
                AppliedAmount = AppliedAmount + (decimal)payment.BillBalance;  
            }  
            else  
            {  
                AppliedAmount = AppliedAmount - (decimal)payment.BillBalance;  
            }  
  
        }  

The SelectedItem property is null.  So I need to handle the click event after the grid has processed the click.  Just not quite sure yet how to do this.

Thanks,
-SId.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 30 Oct 2009, 06:46 AM
Hi Sid,

You can access your data object directly from the DataContext property of this CheckBox.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sid
Top achievements
Rank 1
answered on 30 Oct 2009, 01:53 PM
Vlad,

Thanks, that worked. 

-Sid.
Tags
GridView
Asked by
Sid
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Sid
Top achievements
Rank 1
Share this question
or