i want to put current observablecollection data in list on button click event. bellow is c# code but it gives error : Object reference not set to an instance of an object.
ObservableCollection<CheckInData> _CheckInCollection = new ObservableCollection<CheckInData>();
public ObservableCollection<CheckInData> CheckInCollection
{
get { return _CheckInCollection; }
}
public class CheckInData
{
public string RoomNumber { get; set; }
public decimal Price { get; set; }
public string Currecny { get; set; }
public decimal Discount { get; set; }
public string CheckOut { get; set; }
public int TotalDay { get; set; }
public decimal TotalPrice { get; set; }
public int CheckOutYear { get; set; }
public int CheckOutMonth { get; set; }
public int CheckOutDay { get; set; }
public Boolean IncToday { get; set; }
}
private void btnPrintInvoice_Click(object sender, RoutedEventArgs e)
{
DataToExcel.Invoice inv = new DataToExcel.Invoice();
inv._BilledTo = Guest[0];
foreach (CheckInData coll in _CheckInCollection)
{
for (int i = 0; i < _CheckInCollection.Count; i++)
{
inv._RoomPrice.Add(coll.RoomNumber[i].ToString());
}
}
}
Looks like inv._RoomPrice or coll.RoomNumber is null.