Hi,
I have a problem with the update of the sfDataGrid Control.
I fill the sfDataGrid with a DataSet Table which comes from a SQLiteDataAdapter and has a relation to two SQLite tables.
as an example:
public static DataTable LoadAnfordungsDetails()
{
DataSet ds = new DataSet();
using (SQLiteConnection con = new SQLiteConnection(SQLDataConnection.LoadConnectionString()))
{
con.Open();
SQLiteDataAdapter mitarbeiter = new SQLiteDataAdapter("SELECT * FROM tblMitarbeiter;", con);
mitarbeiter.Fill(ds, "Mitarbeiter");
}
using (SQLiteConnection cnn = new SQLiteConnection(SQLDataConnection.LoadConnectionString()))
{
cnn.Open();
SQLiteDataAdapter details = new SQLiteDataAdapter("SELECT tblMitarbeiter.ID AS ID, tblAnforderungen.Name,tblAnforderungen.Klasse,tblAnforderungen.Beschreibung FROM tblKonfigDetails LEFT JOIN tblAnforderungen ON tblAnforderungen.ID = tblKonfigDetails.AnforderungID LEFT JOIN tblMitarbeiter ON tblMitarbeiter.ID = tblKonfigDetails.MitarbeiterID;", cnn);
details.Fill(ds, "Details");
}
ds.Relations.Add(new DataRelation("KonfigDetails", ds.Tables[0].Columns["ID"], ds.Tables[1].Columns["ID"]));
if(ds.Tables.Count > 0)
{
return ds.Tables[0];
}
else
{
return null;
}
}
I fill the sfDataGrid in the constructor of the form. It all works great too.
But when did changed data I try to make an update to the sfDataGrid with:
sfDataGrid1.View.BeginInit();
sfDataGrid1.DataSource = null;
sfDataGrid1.ClearGrouping();
sfDataGrid1.ClearSorting();
sfDataGrid1.ClearFilters();
sfDataGrid1.TableSummaryRows.Clear();
sfDataGrid1.GroupSummaryRows.Clear();
FillGridView(false);
sfDataGrid1.View.EndInit();
sfDataGrid1.View.Refresh();
This works so far, but as soon as I switch to the sfDataGrid I get in Program.cs -> Application.Run (new FrmMain ()); an exception.
System.ArgumentException: "An item with the same key has already been added."
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unbehandelte Ausnahme</Description><AppDomain>USG Support Agent.exe</AppDomain><Exception><ExceptionType>System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt.</Message><StackTrace> bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
bei Syncfusion.WinForms.DataGrid.DetailsViewHelper.HasChildSource(TableControl tableControl, Int32 rowIndex, RecordEntry record, Dictionary`2&amp; detailsViewDataSource)
bei Syncfusion.WinForms.DataGrid.Renderers.DetailsViewExpanderCellRenderer.OnRender(Graphics paint, Rectangle cellRect, String cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
bei Syncfusion.WinForms.DataGrid.Renderers.GridCellRendererBase.Render(Graphics paint, Rectangle cellRect, String cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
bei Syncfusion.WinForms.DataGrid.GridPainter.DrawCell(Graphics graphics, Rectangle rect, DataColumnBase column, Object cellValue, String formattedText)
bei Syncfusion.WinForms.DataGrid.GridPainter.DrawColumn(Graphics graphics, Rectangle finalSize, DataRowBase dataRow, IEnumerable`1 columns)
.......even more information
An exception "System.ArgumentException" error has occurred in mscorlib.dll.
An item with the same key has already been added.
So i hope i describe the exception well and you can help me.
Greeting
Peschke