0

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

Timofei Davydik
  • 7,244
  • 7
  • 33
  • 59
wawaragna
  • 37
  • 2
  • 10

2 Answers2

1

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.

Diogo Kollross
  • 368
  • 7
  • 11
  • well actually arrayNames is a combo box and i tried to do an alert statement to show the value of the selectedItem but it does show the right value of what i selected – wawaragna Feb 26 '11 at 18:52
  • the error was on the last line. the line studentLessonPlanArray.addItem(temp) – wawaragna Feb 26 '11 at 19:00
0

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

kbgn
  • 856
  • 1
  • 7
  • 16