none
Object Reference not set an instance of an object RRS feed

  • Question

  • I am developing webpart for windows sharepoint services 3.0. I have a drop down list named "RequestIDCombo" which contains it IDs of Requisition list.

    I write code int selected index changed event that when ID change then display item and quantity of that ID which is selected in drop down list.

    i wrote that code also in form load event.

    When the drop down list contains data then it works fine but when it does not contain data then the code in the form load event generate an error "Object reference not set to an instance of an object".

    but when i remove that code from the drop down list then the item and quantity does not display of that ID when the form load.

     

    How can i fix this error?

    Friday, May 7, 2010 6:10 AM

Answers

  • do null checks and skip the routine where you are getting the error

    e.g. if(dropdown!=null) { //do operation} else{// do nothing or show message no data selected }

     


    Manish Sati
    • Marked as answer by Chengyi Wu Monday, May 10, 2010 1:10 AM
    Friday, May 7, 2010 6:59 AM

All replies

  • do null checks and skip the routine where you are getting the error

    e.g. if(dropdown!=null) { //do operation} else{// do nothing or show message no data selected }

     


    Manish Sati
    • Marked as answer by Chengyi Wu Monday, May 10, 2010 1:10 AM
    Friday, May 7, 2010 6:59 AM
  • Thanks Manish.

    it works

    Friday, May 7, 2010 7:10 AM