hello I have a problem filling the datagrid with the data from my BD, the datagrid is a schedule grid with the days of the week, the problem is that I only fill one cell of the datagrid for each day, that is, if I have in the BD three schedules loaded for the same day only shows me 1 (neither the first nor the last, shows any of that day).
Clarifications about things tested at the moment: The query to the BD returns all the values, in the conditional it enters all the times which is correct but I do not know why it does not load the values in the cells, that is to say if I have 10 loaded values in my BD and enter the 10 times to the conditional but only shows some values.
I attach parts of the code
if (query.Count() > 0)
{
int contador = 0;
foreach (var item in query)
{
DateTime DiaTurno = new DateTime(myCal.GetYear(item.fecha_turno), myCal.GetMonth(item.fecha_turno), myCal.GetDayOfMonth(item.fecha_turno), new GregorianCalendar());
int dia = (int)DiaTurno.DayOfWeek;
string horario_turno = item.fecha_turno.ToString("HH:mm");
for (int fila = 0; fila <= AgendaSemanal.Rows.Count - 1; fila++)
{
/*EN ESTE CONDICIONAL ENTRA TODAS LAS VECES QUE DEBE PERO NO ME COMPLETA TODAS LAS CELDAS, SOLO ME COMPLETA 1 POR DIA*/
if (AgendaSemanal.Rows[fila].Cells[0].Value.ToString() == horario_turno)
{
AgendaSemanal.Rows[fila].Cells[dia+1].Value = item.nombre + " " + item.apellido;
AgendaSemanal.Rows[fila].Cells[dia + 1].Style.BackColor=System.Drawing.Color.Salmon;
AgendaSemanal.Rows[fila].Cells[dia + 1].Style.ForeColor = System.Drawing.Color.White;
}
else
{
AgendaSemanal.Rows[fila].Cells[dia + 1].Value = "Libre";
AgendaSemanal.Rows[fila].Cells[dia + 1].Style.BackColor = System.Drawing.Color.Bisque;
AgendaSemanal.Rows[fila].Cells[dia + 1].Style.ForeColor = System.Drawing.Color.Black;
}
}
}
}