Hello,
I want to select gridview row data by clicking on check box column. But when I check checkbox, selectedItem property return null value and I have to select a row and then check checkbox. How can I solve this problem.
Thanks in advance,
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" readOnly="True"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" IsReadOnly="True"/>
<telerik:GridViewDataColumn Header="Select " >
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="checkbox1" IsChecked="{Binding Select,Mode=TwoWay}" HorizontalAlignment="Center" checked="WordCheckBox_Checked" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
private void WordCheckBox_Checked(object sender, RoutedEventArgs e)
{
try
{
MyWord word_obj = new MyWord();
word_obj = dg.SelectedItem as MyWord;
if (word_obj != null)
{
wordList_obj.Add(word_obj);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I want to select gridview row data by clicking on check box column. But when I check checkbox, selectedItem property return null value and I have to select a row and then check checkbox. How can I solve this problem.
Thanks in advance,
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" readOnly="True"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" IsReadOnly="True"/>
<telerik:GridViewDataColumn Header="Select " >
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="checkbox1" IsChecked="{Binding Select,Mode=TwoWay}" HorizontalAlignment="Center" checked="WordCheckBox_Checked" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
private void WordCheckBox_Checked(object sender, RoutedEventArgs e)
{
try
{
MyWord word_obj = new MyWord();
word_obj = dg.SelectedItem as MyWord;
if (word_obj != null)
{
wordList_obj.Add(word_obj);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}