1
我有一個Datagrid顯示數據庫中的數據。 每次我從我的數據花瓶中加載數據時,舊數據會被接收,並且會被新數據替換。將行添加到DataGrid Silverlight
我想要的是保留上一行並將新數據添加到數據網格的末尾。
我的代碼如下所示:
public MainPage()
{
InitializeComponent();
dataGrid1.Columns.Add(new DataGridTextColumn { Header = "Year", Binding = new System.Windows.Data.Binding("year") });
dataGrid1.Columns.Add(new DataGridTextColumn { Header = "One", Binding = new System.Windows.Data.Binding("One") });
dataGrid1.Columns.Add(new DataGridTextColumn { Header = "Two", Binding = new System.Windows.Data.Binding("Two") });
dataGrid1.Columns.Add(new DataGridTextColumn { Header = "Three", Binding = new System.Windows.Data.Binding("Three") });
}
void client_DoWorkCompleted(object sender, DoWorkCompletedEventArgs e)
{
dataGrid1.ItemsSource = e.Result;
}
如何從數據庫中追加新的數據,而不是覆蓋數據? 。