0

I'm getting this error while trying to implement Gantt chart on asp .net.

I have already added my method and it's running in debugging mode and also not giving any information.

This is my code-behind; I'm using Stored procedures and I can't use direct SQL queries from the code.

What I'm trying to do is to invoke methods (SPs) from the database so I can make CRUD operations. Currently I have this but it doesn't render any info.

    using DSProyectosTableAdapters;
    using DSInformesProyectosTableAdapters;
    using Syncfusion.JavaScript.DataVisualization.Models;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web.Services;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class ListarClientesProyectoGantt : clsUsuario
    {
        protected int idPagina = 1;
        protected string sConfSing = "Grafica Gantt";
        protected string sConfPlu = "Graficas Gantt";

        public int? Proyecto
        {
            get
            {
                int? id = null;
                int idAux;
                if (ViewState["idProyecto"] != null && ViewState["idProyecto"].ToString() != "" && int.TryParse(Request.QueryString["P"].ToString(), out idAux))
                    id = idAux;
                else
                {
                    if (Request.QueryString.HasKeys() && Request.QueryString["P"] != null && Request.QueryString["P"].ToString() != "" && int.TryParse(Request.QueryString["P"].ToString(), out idAux))
                    {
                        id = idAux;
                        this.Proyecto = id;
                    }
                    else if (Request.UrlReferrer != null)
                    {
                        if (Request.UrlReferrer.AbsolutePath != Request.Url.AbsolutePath && Request.UrlReferrer.Query != "")
                        {
                            Response.Redirect(string.Format("{0}{1}", Request.Url.AbsolutePath, Request.UrlReferrer.Query));
                        }
                    }
                }
                return id;
            }
            set
            {
                this.ViewState["idProyecto"] = value;
            }
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                if (!this.Proyecto.HasValue)
                {
                       //     Response.Redirect("~/PnlCliente/ListarClientesProyectoGantt.aspx");
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Response.End();
            }
            catch (Exception TrackViewState )
            {
                msj.MostrarMensaje(3, TrackViewState.Message, TrackViewState );
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                msj.Visible = false;

                var MasterP = (Layout2)this.Master;
                MasterP.ConstruirMenu(idPagina, (int)Proyecto.Value, 4);

                this.GanttControl.DataSource = GetGanttData();
                this.GanttControl.DataBind();
            }
            catch (Exception TrackViewState)
            {
                msj.MostrarMensaje(2, TrackViewState.Message, TrackViewState);
            }
        }

        public class ActividadesInfo
        {


            public string TaskId { get; set; }
            public string TaskName { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public string ParentId { get; set; }
            public string Duration { get; set; }
            public string Progress { get; set; }
            public string Predecessor { get; set; }

        }

        public List<ActividadesInfo> GetGanttData()

        {

         sp_GanttTableAdapter DatosTA = new sp_GanttTableAdapter();

         DSProyectos.sp_GanttDataTable DatosT = DatosTA.GetDataIdProyecto(Proyecto);

            List<ActividadesInfo> list = new List<ActividadesInfo>();
            foreach (var DatosR in DatosT)
            {
            list.Add(new ActividadesInfo() { TaskId = DatosR.id.ToString(), ParentId =(DatosR.IsidPadreNull() ? 0 : DatosR.idPadre).ToString(), EndDate = DatosR.IsdFechaFNull() ? DateTime.Now : DatosR.dFechaF, StartDate = DatosR.IsdFechaINull() ? DateTime.Now : DatosR.dFechaI, Duration = "3", Predecessor = null, Progress = "100", TaskName = DatosR.sTitulo });

            }

            return list;
        }


    }


<%@ Page Language="C#" EnableEventValidation="false" MasterPageFile="~/PnlCliente/Layout2.master" AutoEventWireup="true" EnableTheming="false" CodeFile="ListarClientesProyectoGantt.aspx.cs" Inherits="ListarClientesProyectoGantt" %>

<asp:Content ID="Content3" ContentPlaceHolderID="cphFiltro" runat="Server">
    <bit:mensajesv3 ID="msj" runat="server" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cphHead" runat="Server">
    <link href="../App_Themes/samva/assets/syncfusion/Content/ejthemes/ej.widgets.core.min.css" rel="stylesheet" />
    <link href="../App_Themes/samva/assets/syncfusion/Content/ejthemes/material/ej.theme.min.css" rel="stylesheet" />

    <script src="../App_Themes/samva/assets/syncfusion/Scripts/ej/web/ej.web.all.min.js"></script>
    <script src="../App_Themes/samva/assets/syncfusion/Scripts/jsviews.min.js"></script>
    <script src="../App_Themes/samva/assets/syncfusion/Scripts/jsrender.min.js"></script>
    <script src="../App_Themes/samva/assets/syncfusion/Scripts/jquery.easing-1.3.min.js"></script>
            <script type="text/javascript">            

            function ActionComplete(args) {

                if (args.requestType == "indent" || args.requestType == "outdent" || args.requestType == "recordUpdate" || (args.requestType === 'save' && args.modifiedRecord) || args.requestType == "drawConnectorLine") {
                    var ganttRec = [];

                    if (args.requestType == "save")
                        ganttRec.push(args.modifiedRecord);
                    else if (args.requestType == "drawConnectorLine")
                        ganttRec.push(args.currentRecord);
                    else
                        ganttRec.push(args.data); 
                    if (args.updatedRecords && args.updatedRecords.length)
                        ganttRec = ganttRec.concat(args.updatedRecords);
                    updateModifiedGanttRecords(ganttRec);
                }

                else if (args.requestType == "save" && args.addedRecord) {
                    var data = args.addedRecord.item;
                    PageMethods.AddIt(data);


                    if (args.updatedRecords && args.updatedRecords.length)
                        updateModifiedGanttRecords(args.updatedRecords);
                }
                else if (args.requestType == "dragAndDrop") {
                    var ganttRec = [];
                    ganttRec.push(args.draggedRow);
                    if (args.updatedRecords && args.updatedRecords.length)
                        ganttRec = ganttRec.concat(args.updatedRecords);
                    updateModifiedGanttRecords(ganttRec);
                }


                else if (args.requestType == "delete") {
                    var data = args.data.item;
                    PageMethods.DeleteIt(data);
                    if (args.data.hasChildRecords) {
                        deleteChildRecords(args.data);
                    }
                    if (args.updatedRecords && args.updatedRecords.length)
                        updateModifiedGanttRecords(args.updatedRecords);
                }
            }

            function updateModifiedGanttRecords(records) {
                var modifiedRecord = [];
                if (records && records.length) {
                    var length = records.length;
                    for (var i = 0; i < length; i++)
                        modifiedRecord.push(records[i].item);
                }
                PageMethods.UpdateIt(modifiedRecord);
            }


            function deleteChildRecords(record) {
                var childRecords = record.childRecords,
                    length = childRecords.length,
                    count, currentRecord;
                for (count = 0; count < length; count++) {
                    currentRecord = childRecords[count];
                    var data = currentRecord.item;
                    PageMethods.DeleteIt(data);
                    if (currentRecord.hasChildRecords) {
                        deleteChildRecords(currentRecord);
                    }
                }
            }



        </script>
    </asp:Content>


This is my .aspx. I don't know if I have mapped all the necessary fields correctly in my aspx file.

Any suggestion or help will be greatly appreciated. Thanks in advance.


    <asp:Content ID="Content1" ContentPlaceHolderID="cphContenido" runat="Server">

        <ej:Gantt ID="GanttControl" runat="server" AllowSelection="True" DateFormat="M/dd/yyyy"
                TaskNameMapping="TaskName" StartDateMapping="StartDate" AllowDragAndDrop="true"
                EndDateMapping="EndDate" ProgressMapping="Progress" ParentTaskIdMapping="ParentId" DurationMapping="Duration"
                ScheduleStartDate="01/26/2019" ScheduleEndDate="03/20/2019" PredecessorMapping="Predecessor"
                TreeColumnIndex="1" AllowGanttChartEditing="true" ActionComplete="ActionComplete" EnableContextMenu="true">
                <dragtooltip showtooltip="true" />
       <editsettings allowediting="true" allowadding="true" allowdeleting="true" allowindent="true" editmode="normal" rowposition="Child"  />
       </ej:Gantt>



    </asp:Content>

This is the line where is ocurring the breakpoint

8
  • Where in your code is this exception occurring? Also, see this...stackoverflow.com/questions/10555682/… Commented Nov 6, 2019 at 17:10
  • yeah ! when im trying to render the info to the frontend Commented Nov 6, 2019 at 18:00
  • 1
    Ummm I meant more like what line of code, which method. You know the sorts of things you have to figure out when debugging code. Commented Nov 6, 2019 at 19:34
  • protected void Page_Load(object sender, EventArgs e) { try { msj.Visible = false; var MasterP = (Layout2)this.Master; MasterP.ConstruirMenu(idPagina, (int)Proyecto.Value, 4); this.GanttControl.DataSource = GetGanttData(); this.GanttControl.DataBind(); } catch (Exception TrackViewState) { msj.MostrarMensaje(2, TrackViewState.Message, TrackViewState); } } Commented Nov 6, 2019 at 20:13
  • at this point of the code is when my ex breaks and throws the error Commented Nov 6, 2019 at 20:13

1 Answer 1

0

We checked the code snippet shared by you. And we note that, id(null) value is assigned to Proyecto. And in the Page_Init method, this.Proyecto.HasValue condition was checked. We cannot blindly check HasValue of nullable variable. Please check the null condition before proceeding.

public int? Proyecto
    {
        get
        {
           int? id = null;
             //...
            else
            {
             //... 
               {
           this.Proyecto = id;
                }
                //...
            }
            return id;
        }

    }

    protected void Page_Init(object sender, EventArgs e)
    {
        try
        {
            if (!this.Proyecto.HasValue)
            {
                //     
            }
        }
   //...
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.