DataGrid
の名簿情報がほとんど表示されない がありますEmployees
。でテンプレート列を追加しましたCheckBox
。KeyIDs
選択した(選択した)行のすべての行から(DBからバインドされた)を取得したいCheckBox
。これらKeyIDs
を SQL に渡して、選択した行を削除する必要があります ( BtnDeleteSelected_Click
)。助けてください。
これが私のものDataGrid
です:
<DataGrid AutoGenerateColumns="False" Grid.Row="1" Height="555" HorizontalAlignment="Left" Margin="0,5,0,0" Name="dgRosterList" VerticalAlignment="Top" Width="980" ItemsSource="{Binding}" SelectionMode="Single" SelectionUnit="FullRow" CanUserResizeColumns="True" CanUserSortColumns="True" AlternatingRowBackground="Gainsboro" AlternationCount="2" IsEnabled="True" Grid.ColumnSpan="2">
<DataGrid.Columns>
<DataGridTemplateColumn Width="30">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox x:Name="all" Content="" Click="CheckBox_Click"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Checked="chkSelect_Checked" Name="chkSelect"></CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Sl No" Binding="{Binding SlNo}"/>
<DataGridTextColumn Header="Key ID" Binding="{Binding KeyID}" Width="80" Visibility="Hidden"/>
<DataGridTextColumn Header="Emp ID" Binding="{Binding Emp_ID}" Width="80"/>
<DataGridTextColumn Header="Emp Name" Binding="{Binding Emp_Name}" Width="200"/>
<DataGridTextColumn Header="Date" Binding="{Binding PDate, StringFormat={}{0:dd/MM/yyyy}}" Width="100"/>
<DataGridTextColumn Header="Shift" Binding="{Binding Shift_Code}" Width="80"/>
<DataGridTextColumn Header="In Time" Binding="{Binding InTime, StringFormat={}{0:hh:mm}}" Width="80"/>
<DataGridTextColumn Header="Out Time" Binding="{Binding OutTime, StringFormat={}{0:hh:mm}}" Width="80"/>
<DataGridTemplateColumn Header="Half Day" Width="80">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Name="IsHalfDay" Width="15" Height="15" Source="" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding HalfDay}" Value="Yes">
<Setter TargetName="IsHalfDay" Property="Source" Value="../Images/ico_tick.gif"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Off Day" Width="80">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Name="IsOffDay" Width="15" Height="15" Source="" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding OffDay}" Value="Yes">
<Setter TargetName="IsOffDay" Property="Source" Value="../Images/ico_tick.gif"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Delete" Width="75">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="btnDelete" Click="btnDelete_Click" Width="50" Height="20" ToolTip="Delete Roster" CommandParameter="{Binding Path=KeyID}" >
<Image Source="../Images/delete.png" Width="15" Height="19"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Processed" Binding="{Binding Processed}" Visibility="Hidden"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<!--<Image Source="{Binding XPath=media:thumbnail/@url}"
Width="60" Height="60"/>-->
<TextBlock Text="{Binding Path=WeeklyOffs}"/>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>