Please try this code
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if(! IsPostback)
{
this.db = new DB_ProdEntities();
var serverQuery = from a in this.hmdb.Servers
orderby a.ServerID
select a;
dgServer.ItemsSource = null;
dgServer.ItemsSource = serverQuery;
}
}
private void dgServer_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string serverID = (dgServer.SelectedItem as Server).Name;
var componentQuery = from a in db.Components
where a.ServerID == serverID
orderby a.Name
select a;
dgComponent.ItemsSource = null;
dgComponent.ItemsSource = componentQuery;
}