Abhilash J A

Abhilash J A

  • NA
  • 2.4k
  • 580k

error - Unable to cast object of type, wpf Listview

Jan 1 2017 12:49 PM
Hello everyone,
 
After bind listview with linq query, occuring error. 
 
how can I solve this error ? Unable to cast object of type 'Grouping[System.String,<>
  1. public UC_ArcMgmt()  
  2.        {  
  3.            InitializeComponent();  
  4.            DMSBusinessLayer service = new DMSBusinessLayer();  
  5.            listView1.ItemsSource = service.GetArchivedList().SelectMany((x) => new[] { new { Id = x.Id, ArchievedName = x.ArchievedName, UpdatedDate = x.UpdatedDate, FileSize = FormatBytes(x.fsize), docCount = x.docCount } }).Distinct()  
  6. GroupBy((x) => x.ArchievedName);  
  7.        }  
    1.  private void btn_Click(object sender, MouseButtonEventArgs e)  
    2.         {  
    3. foreach (Tble_Documents item in listView1.SelectedItems) /*here showing error*/  
    4.                         {  
    5.                             int DocId = Convert.ToInt32(item.Id);  
    6. }  
    7. }  
                                                                

Answers (5)