i have gridview and i want bind it from data base but it not bind some Cells. it's class of table:
- [Key]
- [Required]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- [Column("FldKeyId")]
- public int MyKeyId { get; set; }
- [Required]
- public Machine Machine { get; set; }
- [Required]
- public Employee Employee { get; set; }
- [Required]
- public Shift Shift { get; set; }
- [Required]
- [Column ("FldStartTime")]
- public DateTime MyStartTime { get; set; }
- [Required]
- [Column ("FldEndTime")]
- public DateTime MyEndTime { get; set; }
- [Column("FldModificationDate")]
- [Required]
- public DateTime ModificationDate { get; set; } [Key]
- [Required]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- [Column("FldKeyId")]
- public int MyKeyId { get; set; }
- [Required]
- public Machine Machine { get; set; }
- [Required]
- public Employee Employee { get; set; }
- [Required]
- public Shift Shift { get; set; }
- [Required]
- [Column ("FldStartTime")]
- public DateTime MyStartTime { get; set; }
- [Required]
- [Column ("FldEndTime")]
- public DateTime MyEndTime { get; set; }
- [Column("FldModificationDate")]
- [Required]
- public DateTime ModificationDate { get; set; }
that's my code for bind
- void RefreshBreakGrid()
- {
- dgvcolDate.DataPropertyName = "ModificationDate";
- dgvcolstarttime.DataPropertyName = "MyStartTime";
- dgvcolendtime.DataPropertyName = "MyEndTime";
- dgvcolemployee.DataSource = Employee.GetAllEmployee();
- dgvcolemployee.DisplayMember = "MyName";
- dgvcolemployee.ValueMember = "MyKeyId";
- dgvcolemployee.DataPropertyName = "Employee";
- dgvcolmachine.DataSource = Machine.GetAllMachine();
- dgvcolmachine.DisplayMember = "MyName";
- dgvcolmachine.ValueMember = "MyKeyId";
- dgvcolmachine.DataPropertyName = "MyName";
- dgvcolshift.DataSource = Shift.GetAllShift();
- dgvcolshift.DisplayMember = "MyName";
- dgvcolshift.ValueMember = "MyKeyId";
- dgvcolshift.DataPropertyName = "Shift";
- _Breaks=Break.GetAllBreak();
- dgvBreak.AutoGenerateColumns = false;
- dgvBreak.DataSource = _Breaks;
- }
that's code for getAllBreaks
- public static List
GetAllBreak() - {
- return new ContexManager().Breaks.Where(c => c.MyKeyId != 0).Include(c => c.Machine).Include(c => c.Employee).Include(c => c.Shift).ToList();
- }
now when it runned in cells of shift it shown classLibrary.classes.shift for machine , employee such as shift what i have to do for it ?
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Karthik ElumalaiPosted Aug 16, 2016, 1:18 AM
sadeq tlbPosted Aug 15, 2016, 8:56 AM
Vinay SinghPosted Aug 15, 2016, 5:55 AM