search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

I cannot load the events when I put if(IsPostBack)

Asked by Ernesto Contreras
5 years ago.

If I set the condition of IsPostBack, then the dayPIlot control doesn't load anything! I'm writing the same logic that comes in the trial. DayPilot 2018.43692

First assign in the load the start dates and days and then I call UpdateScheduler ();

The strange thing is that although I'm not throwing any event, the form returns to the load again.

that is, I have load process and then reload load com if I had done a postback. and I've never done postback

MyCode -->

protected void Page_Load(object sender, EventArgs e)
{
// DiagramaGantt.DynamicLoading = true;
//if (!IsPostBack) // Quito is postback momentaneamente, sino no se dibuja el gantt.
//{
if (!String.IsNullOrEmpty(Request.QueryString["idPedido"])) {
IdPedido = Request.QueryString["idPedido"];
}
else {

Response.Redirect("../Produccion/Pedidos.aspx");
}

var start = (GetStart() ?? DateTime.Today).Date;
var end = GetEnd() ?? DateTime.Today.AddDays(1);

DiagramaGantt.StartDate = start;
DiagramaGantt.Days = (int)Math.Ceiling((end - start).TotalDays); //Al restar dos DateTime devuelve un TimeSpan con la info del periodo.

//DiagramaGantt.CellWidthSpec = DayPilot.Web.Ui.Enums.Scheduler.CellWidthSpec.Auto
DiagramaGantt.Separators.Add(DateTime.Parse("2018/12/21"), Color.Red); // solo para pruebas.
DiagramaGantt.Separators.Add(DateTime.Now, Color.Red); // solo para pruebas.

LoadResources();

if (!IsPostBack)
{

UpdateScheduler();

}

}

private void UpdateScheduler()
{

TransferDatosPlanificaciónPedido(IdPedido);
DiagramaGantt.DataSource = obtenerDatosPlanificaciónPedido_List(IdPedido);
DiagramaGantt.DataBind();
// DiagramaGantt.Update();

}

private void LoadResources()
{
DiagramaGantt.DynamicLoading = true; // Importante agregar carga dinamica sino no se dibuja el gantt. E.C
DiagramaGantt.Resources.Clear();
//DiagramaGantt.RowHeaderWidthAutoFit = false;
if (DiagramaGantt.HeaderColumns.Count == 0)
{
DiagramaGantt.HeaderColumns.Add(new RowHeaderColumn("Partida", 220));
DiagramaGantt.HeaderColumns.Add(new RowHeaderColumn("Inicio", 75));
DiagramaGantt.HeaderColumns.Add(new RowHeaderColumn("Fin", 75));
DiagramaGantt.HeaderColumns.Add(new RowHeaderColumn("Días", 30));
}
foreach (DataRow dr in PlanificacionPedido.Rows)
{
if (dr["fechaInicioEjecucion"] != DBNull.Value && dr["fechaFinEjecucion"] != DBNull.Value)
{
if (DiagramaGantt.Resources.FindById(Convert.ToString(dr["idPedidoDetalleGantt"])) == null)
{
// Agregar recurso 'Descripcion'
DiagramaGantt.Resources.Add((string)dr["Descripcion"], Convert.ToString(dr["idPedidoDetalleGantt"]));

// Agregar columna 'fechaInicioEjecucion' al recurso previo.
DiagramaGantt.Resources.FindById(Convert.ToString(dr["idPedidoDetalleGantt"])).Columns
.Add(new ResourceColumn(((DateTime)dr["fechaInicioEjecucion"]).ToString("dd/MM/yyyy")));

// Agregar columna 'fechaFinEjecucion' al recurso previo.
DiagramaGantt.Resources.FindById(Convert.ToString(dr["idPedidoDetalleGantt"])).Columns
.Add(new ResourceColumn(((DateTime)dr["fechaFinEjecucion"]).ToString("dd/MM/yyyy")));

// Agregar columna 'Días' al recurso previo.
DiagramaGantt.Resources.FindById(Convert.ToString(dr["idPedidoDetalleGantt"])).Columns
.Add(new ResourceColumn(" " + dr["Duracion"].ToString() )); // Le coloco espacio porque el html aparece luego en la exportacion. Bug del control.
}
}
}

}

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.