This is a migrated thread and some comments may be shown as answers.

See if cell has nothing and then hide linkbutton if nothing

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 23 Aug 2011, 08:19 PM
I have a radgrid that has 10 columns.  What I need to do is check a name in column 8 and if the name field is blank I want to turn off the link buttons that sit in columns 9 and 10.  Here is what I have that I got off a telerik help site but I cannot get at the names to work to turn off the linkbuttons.  However below does not thourhg an error but when I try to assign the text nothing happens??


 Protected Sub myGridPositions_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myGridPositions.ItemDataBound
        For Each item As GridDataItem In myGridPositions.Items
            Dim name As TableCell = DirectCast(item("strFullName"), TableCell)
            If name.Text = Nothing Then
                turn off link buttons in columns 9, 10.
            End If
        Next
    End Sub

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Aug 2011, 06:30 AM
Hello Kevin,

Try the following code snippet to achieve your scenario.
VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim cell As TableCell = DirectCast(item("OrderID"), TableCell)
        If cell.Text = " " Then
            Dim lnk As LinkButton = DirectCast(item.FindControl("link1"), LinkButton)
            lnk.Enabled = False
        End If
    End If
End Sub

Thanks,
Princy.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or