10892 : I have difficulties with adding links to my Gantt (Databound).

Question

I have difficulties with adding links to my Gantt (Databound). I do the following (see code below)to add the link to my dataset and get a nullReferenceException on the last line when adding the new row to the dataset.< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

What happens is that in your TimeItemLink.cs, UpdateValue() in the line int y = TimeItemLinks.IndexOf(aLink) the “list” variable used in IndexOf() is null.

 

Can you give me any clue on that please?

 

 

 

startItemRow = ((DataRowView)(linkStartItemUserData).First).Row;    // attività owner del link da creare;

        stopItemRow = ((DataRowView)((Pair)endItem.UserReference).First).Row;

        startId = Convert.ToInt32(startItemRow[“ID”]);

        stopId = Convert.ToInt32(stopItemRow[“ID”]);

 

       

        row = chartData.Tables[“link”].NewRow();

        row[“id”] = ++dataRowCount;

        row[“owner”] = startId;

        row[“target”] = stopId;

        row[“link_type”] = “StartToFin”;    //nuovo link sempre

        row[“color”] = “blue”;

        chartData.Tables[“link”].Rows.Add(row);

Answer

It is important that the TimeItem set the Identity field when using databound links.

 

TimeItem.Identity:  Identity is used to tie databound timeitemlinks. Set Identity to the primary key for your time items. If the time items are databound; assign the TimeItemDataConnect.NameInDS_Identity to the primary key column of your time item row