I have problems showing my data inside the data into the data grid view. Can anyone help to solve because they never prompt me any errors while compiling and there are also data inside the database. What comes out inside the data grid view is only the columns and no data inside.
private void LoadAllEmpShift()
{
using (testEntities Setupctx = new testEntities())
{
var Viewemp = from ES in Setupctx.employeeshifts
join shifthour sh in Setupctx.shifthours on ES.ShiftHourID equals sh.idShiftHours
select new
{
ES.idEmployeeShift,
ShiftHour_Start = sh.shiftTiming_start,
ShiftHour_Stop = sh.shiftTiming_stop,
ES.EmployeeName,
ES.StartTime,
ES.EndTime,
ES.Date
};
dgvShift.DataSource = Viewemp;
}
}
Any help will be greatly appreciated.
After setting the
DataSourceproperty, you need to callEdit:
I believe the above is for a DataGrid / GridView (in case anyone is using those controls).
For DataGridView, you need to have a BindingSource.
Add the
BindingSourcecontrol to your form, then set theDataSourceproperty of theBindingSourcetoViewemp