This is my collection :
ObservableCollection<CheckInData> _CheckInCollection = new ObservableCollection<CheckInData>();
public ObservableCollection<CheckInData> CheckInCollection
{
get { return _CheckInCollection; }
}
public class CheckInData
{
public string RoomNumber { get; set; }
public string Price { get; set; }
public string Currecny { get; set; }
public string Discount { get; set; }
public string CheckOut { get; set; }
public string 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; }
public string CheckIn { get; set; }
public decimal MoneyRate { get; set; }
}
I have one class where i save export my collection this way:
foreach (CheckInData coll in CheckInCollection)
{
var roomType = (from d in db.SelectRooms where d.roomnumber == coll.RoomNumber select d.roomtype).SingleOrDefault();
inv._RoomType.Add(roomType.ToString());
inv._RoomNumber.Add(coll.RoomNumber.ToString());
inv._CheckIn.Add(coll.CheckIn);
inv._CheckOut.Add(coll.CheckOut);
inv._DayNight.Add(coll.TotalDay);
inv._RoomPrice.Add(coll.Price);
inv._Discount.Add(coll.Discount);
}
This code works perfectly. I have list view which is binding with this observable collection so my question is how i can insert into inv._RoomType, inv._RoomNumber… only that collection which(rows) are selected in listview. inv._RoomNumber.Add(coll.RoomNumber(listview selected items? ??)) Thanks
You need to add an IsSelected property to your CheckInData class and then bind to that from the ListView. You can then say