C
Chris
Hello All,
I've got a problem that is probably very simple but it just isn't
working right for me.
I've been reading Scott Mitchell's article on DataGrids
(http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx) and
applying a lot of techniques to my app. I added delete button column
and I added an OnClick attribute on the ItemDataBound event that adds
the eventhandler to the button. The problem is that I get "Object
reference not set to an instance of an object." after the first row of
the datagrid is created.
Any ideas?
Chris
=============================================================================
Sub dgTierCodes_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles dgTierCodes.ItemDataBound
'Check for header and footer
If e.Item.ItemType <> ListItemType.Header And _
e.Item.ItemType <> ListItemType.Footer Then
'Now reference the LinkButtonControl that the Delete
'ButtonColumn is referenced to
Dim btnDeleteButton As LinkButton = _
e.Item.Cells(1).FindControl(0)
'Now create an OnClick EventHandler
btnDeleteButton.Attributes("onclick") = _
"javascript:return " & _
"confirm('Are you sure you want to delete Tier Code "
& _
DataBinder.Eval(e.Item.DataItem, "TierCode") & "?')"
End If
End Sub
=============================================================================
I've got a problem that is probably very simple but it just isn't
working right for me.
I've been reading Scott Mitchell's article on DataGrids
(http://aspnet.4guysfromrolla.com/articles/090402-1.2.aspx) and
applying a lot of techniques to my app. I added delete button column
and I added an OnClick attribute on the ItemDataBound event that adds
the eventhandler to the button. The problem is that I get "Object
reference not set to an instance of an object." after the first row of
the datagrid is created.
Any ideas?
Chris
=============================================================================
Sub dgTierCodes_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles dgTierCodes.ItemDataBound
'Check for header and footer
If e.Item.ItemType <> ListItemType.Header And _
e.Item.ItemType <> ListItemType.Footer Then
'Now reference the LinkButtonControl that the Delete
'ButtonColumn is referenced to
Dim btnDeleteButton As LinkButton = _
e.Item.Cells(1).FindControl(0)
'Now create an OnClick EventHandler
btnDeleteButton.Attributes("onclick") = _
"javascript:return " & _
"confirm('Are you sure you want to delete Tier Code "
& _
DataBinder.Eval(e.Item.DataItem, "TierCode") & "?')"
End If
End Sub
=============================================================================