Get checkbox value from datagrid?

<DataGridTemplateColumn Header="IsAdmin">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <CheckBox Name="IsAdminCheckBox" IsChecked="{Binding Path=IsAdmin}" Click="IsAdmin_Click" CommandParameter="{Binding Path=Id}"/>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

This is the code that I have for the datagrid in my program. In the CS file, in the click event, I want to see if it will be checked whether it has changed to a mark or not checked so that I can process in the database, changing the user from admin to admin and vice versa. However, just calling IsAdminCheckBox does not work, because it cannot find it, and also calls datagridName.IsAdminCheckBox does not work. Does anyone know how to access checkbox status?

+3
source share
1 answer

You cannot access the checkbox this way, because there can be more than one of them, the name is really only inside DataTemplate.

sender CheckBox, , IsChecked. - Checked Uncheked.

, - , , .

+2

All Articles