My Grid is already filled with data but when i change the mark and press submit direct it take the old value
if i pressed enter and the pressed submit it take the new value
I need to take the new value if i pressed submit direct
please find below all code used
Datagrid:
<DataGrid x:Name="GrdExamCheck" AutoGenerateColumns="False" HorizontalAlignment="Left" Background="{x:Null}" VerticalAlignment="Stretch" Canvas.Top="10" FontFamily="Times New Roman" Width="997" FontWeight="Bold" Canvas.Left="10" >
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Bottom"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Student ID" Visibility="Hidden" Binding="{Binding StuId}"/>
<DataGridTemplateColumn Header="Student" Width="180" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding StuImage}" Width="50" Height="50" />
<TextBlock Text="{Binding StuName}" VerticalAlignment="Bottom" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Mark" Width="100" Binding="{Binding CheckMark}"></DataGridTextColumn>
<DataGridTemplateColumn Header="Factor" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Factor}" TextAlignment="Center" VerticalAlignment="Bottom" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Versions" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding CheckUpdated}" VerticalAlignment="Bottom" TextAlignment="Center" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Remark" Width="200" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding Remark}" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" FontFamily="Times New Roman" FontWeight="Bold" FontSize="13" Foreground="Black" BorderBrush="{x:Null}" Background="{x:Null}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Absent" Width="70">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="BtnAbsent" Content="" Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnAbsent_Click" >
<Button.Background>
<ImageBrush ImageSource="/School Manager v001;component/Pics/absent.ico" Stretch="Uniform"/>
</Button.Background>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Submit" Width="70">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="BtnSubmit" Content="" Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnSubmit_Click" >
<Button.Background>
<ImageBrush ImageSource="/School Manager v001;component/Pics/submitMark.ico" Stretch="Uniform"/>
</Button.Background>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Attach" Width="70">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="BtnAttach" Content="" Width="40" Height="40" BorderBrush="{x:Null}" Click="BtnAttach_Click" >
<Button.Background>
<ImageBrush ImageSource="/School Manager v001;component/Pics/attachment.ico" Stretch="Uniform"/>
</Button.Background>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Submit click code :
var mark = GrdExamCheck.CurrentItem as Mark;
if (mark != null)
{
InsertMark(int.Parse(LbExamIdContent.Content.ToString()), mark.StuId, DateTime.Now.ToShortDateString(), mark.Remark, Convert.ToDecimal(mark.CheckMark), Convert.ToDecimal(LbFactorContent.Content.ToString()));
}
FillClassStudentList(int.Parse(LbCLassIdContent.Content.ToString()));
Mark Class for binding:
public class Mark
{
public int CheckId { set; get; }
public int StuId { set; get; }
public string StuName { set; get; }
public string Date { set; get; }
public int ExamId { set; get; }
public string CheckMark { set; get; }
public decimal Factor { set; get; }
public string Remark { set; get; }
public int StuPicid { set; get; }
public BitmapImage StuImage { set; get; }
public string CheckUpdated { get; set; }
}
Please guys help
What I have tried:
i tried the code of click and tried to refresh the Grid item
also i tried to get currentitem
but it did not work