在datagrid中添加模板列imagebutton绑定一个ImageUrl地址,编译时出现“未将对象引用设置到对象的实例”是怎么会事
源代码:
    Function FixImgCheck(ByVal theString As Integer) As ImageButton
        If theString = 0 Then
            FixImgCheck.ImageUrl = "../image/notconfirm.gif"
        End If
        If theString = 1 Then
            FixImgCheck.ImageUrl = "../image/confirm.gif"
        End If
    End Function提示:FixImgCheck.ImageUrl = "../image/notconfirm.gif" 出错

解决方案 »

  1.   

    楼主这个function是做什么用的,在其他代码?光这样写看不出.
      

  2.   

    还有,FixImgCheck应该是个函数名吧,能用做FixImgCheck.ImageUrl ??
      

  3.   

    说的简单点就是一句话,FixImgCheck这个函数不应该有ImageUrl 这个属性.
      

  4.   

    Try:Function FixImgCheck(ByVal theString As Integer) As ImageButton
            dim FImg As ImageButton
            If theString = 0 Then
               FImg.ImageUrl = "../image/notconfirm.gif"
            End If
            If theString = 1 Then
                FImg.ImageUrl = "../image/confirm.gif"
            End If
            FixImageCheck=Fimg
        End Function
    Vb语法不熟,不知道有没有错.
      

  5.   

    FixImgCheck.ImageUrl 
    这个不对,FixImgCheck是函数,而非ImageButton,参考风林火山的
      

  6.   

    我写错了!不过还是非常感谢大家的支持!
    应该是
           Function  FixImgCheck(ByVal  theString  As  Integer)  As  String
                   If  theString  =  0  Then  
                           FixImgCheck  =  "../image/notconfirm.gif"  
                   End  If  
                   If  theString  =  1  Then  
                           FixImgCheck =  "../image/confirm.gif"  
                   End  If  
           End  Function  
    再绑定ImageUrl即可!