0) Instead of providing the filename like you're doing, create a string constant set to the filename, and then use the filename constant. Doing this will make it possible to change the filename in one place and not worry about whether or not you missed a place that required the change.
const string __FILENAME__ = @"../../Data/gemi1/gemi1s1.xml";
private void silbtn2_Click(object sender, EventArgs e)
{
XDocument x = XDocument.Load(__FILENAME__);
x.Root.Elements().Where(a => a.Element("id").Value == siltxt2.Text).Remove();
x.Save(__FILENAME__);
yukle();
}
1) Don't bind your datagrid control
ItemsSource
property to a
DataTable
. Instead, create an viewmodel entity (inheriting from
INotifyPropertyChanged
), and put those entities into an
ObservableCollection
. Finally, bind your datagrid's ItemsSource property to the collection. When you do this, all you have to worry about is updating the collection, and the UI will change automatically.