FLEX inserting an object to a data grid

157 Views Asked by At

whenever i insert an object to this datagrid it show this error

TypeError: Error #1009: Cannot access a property or method of a null object reference. at Forms::LessonPlan/addLesson_clickHandler()

this is my code for inserting an object

var obj:Object = new Object();
var temp:Object = new Object();
obj.activityid = arrayNames.selectedItem.activityid;
obj.lessonid = getLessonIDResult.lastResult ;
obj.time = durationCombo.selectedItem;
obj.status = "active";
obj.activityname = arrayNames.selectedItem.activityname;
temp = ({activityname:obj.activityname,time:obj.time});
studentLessonPlanArray.addItem(temp);

please help me

2

There are 2 best solutions below

0
On

Make sure the the reference(studentLessonPlanArray) is instantiated before it is called. Also check this link.

2
On

Without knowing at what line the error occurs, and assuming that arrayNames and studentLessonPlanArray are properly initialized, it seems that there is no item selected in the List/DataGrid named arrayNames.