在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" 出错
源代码:
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" 出错
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语法不熟,不知道有没有错.
这个不对,FixImgCheck是函数,而非ImageButton,参考风林火山的
应该是
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即可!