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

GridCheckBox Column value

3 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan Hughes
Top achievements
Rank 1
Bryan Hughes asked on 12 Nov 2013, 10:37 PM
How can I access the value of GridCheckBox column during ItemDataBound Event?

I need access the value and if condition is true hide delete link button.  I have tried many different ways with no luck so far.

Here is my code
Protected Sub PeoplegridCheckrow(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
            Dim relationship As String = dataItem("Relationship").Text
            Dim bJournalName As Boolean = (Boolean.Parse(dataItem("UseAsJournalName").Text))
            If relationship = "Family Member" And bJournalName = True Then
                CType(dataItem("DeleteButton").Controls(0), LinkButton).Visible = False
            End If
        End If
    End Sub

Thank you for the help.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 13 Nov 2013, 03:57 AM
Hi Bryan,

Please try the following code snippet to access a GridCheckBoxColumn in ItemDataBound.

ASPX:
<telerik:GridCheckBoxColumn DataField="IsTrue" HeaderText="IsTrue" UniqueName="GridCheckBoxColumn">
</telerik:GridCheckBoxColumn>
<telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
</telerik:GridButtonColumn>

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 check As CheckBox = DirectCast(item("GridCheckBoxColumn").Controls(0), CheckBox)
        If check.Checked = False Then
            item("DeleteColumn").Controls(0).Visible = False
        End If
    End If
End Sub

Thanks,
Princy
0
Bryan Hughes
Top achievements
Rank 1
answered on 13 Nov 2013, 08:22 PM
Thanks for the help, but I tried that also and it did not work.

Protected Sub PeoplegridCheckrow(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles peoplegrid.ItemDataBound
        If TypeOf e.Item Is GridDataItem Then
            Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim relationship As String = dataItem("Relationship").Text
            Dim chkBox As CheckBox = DirectCast(item("UseAsJournalName").Controls(0), CheckBox)
            'Dim bJournalName As Boolean = (Boolean.Parse(dataItem("UseAsJournalName").Text))
            If relationship = "Family Member" And chkBox.Checked = True Then
                CType(dataItem("DeleteButton").Controls(0), LinkButton).Visible = False
            End If
        End If
    End Sub
0
Bryan Hughes
Top achievements
Rank 1
answered on 13 Nov 2013, 11:34 PM
Thanks for the help I got it to work.  I was mixing Ctype and DirectCase.
Tags
Grid
Asked by
Bryan Hughes
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Bryan Hughes
Top achievements
Rank 1
Share this question
or