# ServerFeed [C#]

This example shows how to retrive groups and server feeds from specific manager, and how to edit specific server feed.

[C#]

       //Initialize the XAML object and retrieve group from server by login
       public ServerFeed(string login, string password)
       {
           InitializeComponent();

           //Login and retrive group
           List<View_Group> listResult;
           sample.GetGroup(out listResult, login, password);

           //Bind group to TreeList
           treeGroup.ItemsSource = TreeNode.GetTreeNode(listResult);
       }

[C#]

       //Select group and retrive coresponding server feed
       private void treeGroup_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
       {
           //Retrive server feed by group
           List<XMLMedia> listResult;
           sample.GetXMLMedia(out listResult, (treeGroup.SelectedItem as TreeNode).Id??0);

           //Bind server feed to combobox
           comboFeed.ItemsSource = (from l1 in listResult where l1.TypeId == 1 select l1).ToList();
       }

[C#]

       //Select server feed and retrive coresponding data
       private void comboFeed_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           if (comboFeed.SelectedItem == null)
           {
               gridFeedData.ItemsSource = null;
               return;
           }

           //Display only 30 row
           ObservableCollection<FeedRow> listRow = new ObservableCollection<FeedRow>();
           for (int i = 0; i < 30; i++)
           {
               listRow.Add(new FeedRow((comboFeed.SelectedItem as XMLMedia).Id, i));
           }

           //Retrive server feed data
           List<XMLMediaData> listResult;
           sample.GetXMLMediaData(out listResult, (comboFeed.SelectedItem as XMLMedia).Id);

           //Update list from the retrived data
           for (int i = 0; i < listResult.Count; i++)
           {
               listRow[listResult[i].RowIndex ?? 0].ListColData.Add(listResult[i]);
           }

           //Bind data to DataGrid
           gridFeedData.ItemsSource = listRow;
       }

[C#]

       //Save server feed changes
       private void btnValidate_Click(object sender, RoutedEventArgs e)
       {
           //Retrive changed data
           List<XMLMediaData> listResult = new List<XMLMediaData>();
           (from l1 in (gridFeedData.ItemsSource as ObservableCollection<FeedRow>) select l1.ListColUpdated).ToList().ForEach(x => listResult.AddRange(x)); ;

           //Update data
           sample.SetXMLMediaData(listResult);
       }