在DropDownList3 = e.Item.FindControl("DropDownList3")之后加一个判断:
If DropDownList3 Is Nothing Then Exit Sub
另外,把DropDownList3 = e.Item.FindControl("DropDownList3")改成:
DropDownList3 = CType(e.Item.FindControl("DropDownList3"), DropDownList)

解决方案 »

  1.   

    我跟蹤過,因为ItemDataBound并不仅仅是在你DataBind调用之后,应该是create的时候就开始调用。所以,你应该象icyer写的那样,或者是这样:
    if(e.Item.ItemIndex<0)return;
      

  2.   

    在ItemDataBound中,是依次邦定一行的:Header -> Item ... Item -> Footer -> Pager,当处于Header、Footer、Pager的时候,显然不能找到DropDownList3这个控件,而这些行中e.Item.ItemIndex的值为-1。而在Item的行(包括Item、EditItem等),e.Item.ItemIndex为0到DataGrid1.Items.Count中的数值。
      

  3.   

    在ItemDataBound中,是依次邦定一行的:Header -> Item ... Item -> Footer -> Pager,当处于Header、Footer、Pager的时候,显然不能找到DropDownList3这个控件,而这些行中e.Item.ItemIndex的值为-1。而在Item的行(包括Item、EditItem等),e.Item.ItemIndex为0到DataGrid1.Items.Count中的数值。