Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

disable/hide editbutton

0 views
Skip to first unread message

Beate Wågen

unread,
Oct 18, 2002, 6:54:57 AM10/18/02
to
I want to be able to disable or hide the Edit button in some selective rows
of the datagrid.

This based on whether a field (punchlist) contains 0, which is when the Edit
button will appear. Any other number in the field, the Edit- button is
supposed to be disabled.

Here is the code I have been trying:

Sub lnk_Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType <> ListItemType.Item AND e.Item.ItemType <>
ListItemType.AlternatingItem Then
return
End If

Dim link As Hyperlink
link = e.Item.Cells(0).Controls(0)

If e.Item.DataItem.Row("punchlist") = "0" Then
link.Visible = True
Else
link.visible = False
End If

End Sub

The only thing I have gained from this code is that only one row appears in
the datagrid...

Hope someone can help.

Gregor Streng

unread,
Oct 18, 2002, 12:30:39 PM10/18/02
to
Hello Beate,

I suppose the sub lnk_Item_Bound is bound to the datagrid event
ItemDataBound.

Why do you return on ListItemType.Item and ListItemType.AlternatingItem?
These are actually the ListItemTypes you want to edit.

Try if this solves your issues.

Private Sub lnk_Item_Bound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or (itemType =
ListItemType.Header) Or _
(itemType = ListItemType.Footer)) Then
Return
Else

> Dim link As Hyperlink
> link = e.Item.Cells(0).Controls(0)
>
> If e.Item.DataItem.Row("punchlist") = "0" Then
> link.Visible = True
> Else
> link.visible = False
> End If

End If
End Sub

Hope this helps,
Gregor


"Beate Wågen" <beate...@sireko.no> wrote in message
news:OqEzjSpdCHA.2408@tkmsftngp11...

0 new messages