private void Printit_Click(object sender, RoutedEventArgs e) { IEnumerable <dhParty> tempData = partyList.Items.Cast <dhParty>().ToList(); DataTable SelectedParties = new DataTable(); SelectedParties = Globalized.ToDataTable(tempData, "Parties"); DataSet ds = new DataSet(); // dsGeneral.dtPosItemsDataTable dt = iFacede.GetItems(Globalized.ObjDbName, objPrint); ds.Tables.Add(SelectedParties); if ((ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0)) { string ReportDisc = BL.MsgTextCollection.MsgsList.Where(x => x.Key == "DP01").FirstOrDefault().Value; PrintUtilities.printDoc("Parties.xaml", ds, "Parties Report", true, ReportDisc); } else { string msg = "There is not enough data to generate the report."; Globalized.setException(msg, lblErrorMsg, MsgType.Error); } // MessageBox.Show(tmptb.Rows.Count.ToString()); }