Hi
I’m testing the GridView and have a problem with adding new rows. I get a new row twice in the grid when I click again the AddNew button.
Here is my code:
<telerik:RadGridView ItemsSource="{Binding ElementName=TQualityDomainDataSource, Path=Data}" |
Name="DG" |
AutoGenerateColumns="False" |
Margin="0,100,0,20" |
IsBusy="{Binding IsBusy}" |
AlternationCount="4" ColumnWidth="80"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn x:Name="qua_emissionColumn" DataMemberBinding="{Binding Path=qua_emission}" Header="Emission" /> |
<telerik:GridViewComboBoxColumn x:Name="qua_ene_idComboColumn" Header="Energieträger" Width="200" |
SortMemberPath="tEnergie.ene_name" |
ItemsSource="{Binding Source={StaticResource ENERGIE}, Path=Data}" |
DisplayMemberPath="ene_name" |
SelectedValueMemberPath="ene_id" |
DataMemberBinding="{Binding qua_ene_id, Mode=TwoWay}" /> |
<telerik:GridViewDataColumn x:Name="Min_CH4Column" DataMemberBinding="{Binding Path=qua_O_CH4}" Header="CH4 o" DataFormatString="{}{0:N4}" TextAlignment="Right" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
<riaControls:DomainDataSource AutoLoad="False" |
d:DesignData="{d:DesignInstance my:tQuality, CreateList=true}" Height="0" |
Name="TQualityDomainDataSource" |
QueryName="GetTQualityArchivQuery" Width="0"> |
<riaControls:DomainDataSource.DomainContext> |
<my:KeefDS /> |
</riaControls:DomainDataSource.DomainContext> |
<riaControls:DomainDataSource.QueryParameters> |
<riaControls:Parameter ParameterName="ArcID" Value="{Binding ElementName=ArcIDTextBox, Path=Text}" /> |
</riaControls:DomainDataSource.QueryParameters> |
</riaControls:DomainDataSource> |
Private Sub BtNew_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles BtNew.Click |
DG.BeginInsert() |
End Sub |
Private Sub DG_AddingNewDataItem(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs) Handles DG.AddingNewDataItem |
Try |
Dim newTM As New tQuality |
With newTM |
.qua_ene_id = 5 |
.qua_id = Guid.NewGuid |
.qua_arc_id = CInt(Arc_idComboBox.SelectedValue) |
.qua_EmissionsKlasse = 0 |
.qua_emission = _LastEmission |
End With |
e.NewObject = newTM |
TQualityDomainDataSource.DataView.Add(e.NewObject) |
Catch ex As Exception |
System.Windows.MessageBox.Show(ex.Message + vbCrLf + vbCrLf + ex.ToString, "Add Error", System.Windows.MessageBoxButton.OK) |
End Try |
End Sub |
Thanks for help.
Peter