I have a checkbox defined in a template. The purpose of the grid is to list attendees of a meeting. When I click on the checkbox, I want to get the value from the colWorkplaceID column. I'm struggling on how to do that. Any pointers would be greatly appreciated. This is the definition of the gridview. The two columns that I'm interested in are colWorkplaceID and colAttending.
The click event on the checkbox works fine. I simply cannot figure out how to get the workplaceID from the cell in the same row as the checbox. The ParentRow gives me lots of information about the cells, but I'm struggling on how to get the underlying data value.
Any pointers are appreciated. Thanks.
Sherri.
<
telerik:RadGridView
x:Name
=
"RadGridViewAttendees"
CanUserFreezeColumns
=
"False"
RowIndicatorVisibility
=
"Collapsed"
telerik:Theming.Theme
=
"Windows7"
AutoGenerateColumns
=
"False"
CanUserDeleteRows
=
"False"
CanUserInsertRows
=
"False"
CanUserReorderColumns
=
"False"
ClipboardCopyMode
=
"Default"
ClipboardPasteMode
=
"None"
ShowGroupPanel
=
"False"
IsReadOnly
=
"True"
EnableColumnVirtualization
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
UniqueName
=
"colWorkplaceID"
Header
=
"WorkplaceID"
DataMemberBinding
=
"{Binding WorkplaceID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colAttending"
Header
=
"Attending"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
CheckBox
IsChecked
=
"{Binding Attending, Mode=TwoWay}"
Click
=
"CheckBox_Click"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
UniqueName
=
"colInsured"
Header
=
"Insured"
DataMemberBinding
=
"{Binding InsuredName}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colContact"
Header
=
"Contact"
DataMemberBinding
=
"{Binding InsuredPrimaryContactName}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colAddress"
Header
=
"Address"
DataMemberBinding
=
"{Binding WorkplaceAddress1And2}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colCityStateZip"
Header
=
"City, State, ZIP"
DataMemberBinding
=
"{Binding WorkplaceCityStateZip}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colPhone"
Header
=
"Phone"
DataMemberBinding
=
"{Binding InsuredPrimaryContactPhone}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"colIndustry"
Header
=
"Industry"
DataMemberBinding
=
"{Binding InsuredIndustryCode}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
The click event on the checkbox works fine. I simply cannot figure out how to get the workplaceID from the cell in the same row as the checbox. The ParentRow gives me lots of information about the cells, but I'm struggling on how to get the underlying data value.
private
void
CheckBox_Click(
object
sender, RoutedEventArgs e)
{
CheckBox cb = (CheckBox)e.OriginalSource;
if
(cb.IsChecked.HasValue)
{
if
((
bool
)cb.IsChecked)
{
GridViewCell cell = (GridViewCell)cb.Parent;
GridViewRowItem gvri = cell.ParentRow;
MessageBox.Show(
"Clicked"
);
}
else
{
}
}
}
Any pointers are appreciated. Thanks.
Sherri.