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

not able to hide Delete link

2 Answers 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 04 Jun 2010, 08:57 AM
hi

I don't seem to be able to hide the Delete command based on certain condition? These are my code:

 <telerik:GridBoundColumn DataField="Invitation_Date" DataType="System.DateTime"
            HeaderText="Invitation Date" DataFormatString="{0:dd/MM/yyy}" SortExpression="Invitation_Date"
            UniqueName="Invitation_Date">
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Delete" ConfirmText="Are You Sure?"
            HeaderText="Delete" Text="Delete" UniqueName="DeleteColumn">
        </telerik:GridButtonColumn>

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            If item("Invitation_Date").Text Is Nothing Then
                Dim btn As LinkButton = DirectCast(item("DeleteColumn").Controls(0), LinkButton)
                btn.Visible = False
            End If
        End If

    End Sub

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 04 Jun 2010, 10:40 AM
Hello,

 Since the empty cell in grid is rendered in HTML as "&nbsp;", you have to compare the cell with "&nbsp;" to check whether the cell contains any value or not .

VB.Net
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) 
    If TypeOf e.Item Is GridDataItem Then 
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
        If item("Invitation_Date").Text = "&nbsp;" Then 
            Dim btn As LinkButton = DirectCast(item("DeleteColumn").Controls(0), LinkButton) 
            btn.Visible = False 
        End If 
    End If 
End Sub 
 

Regards,
Shinu.


0
L
Top achievements
Rank 1
answered on 04 Jun 2010, 02:51 PM
Thanks shinu
Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
L
Top achievements
Rank 1
Share this question
or