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

Item show/hide issue..

2 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Milan Gurung
Top achievements
Rank 1
Milan Gurung asked on 26 Mar 2009, 02:12 PM
Hi,

I got a rad grid with one of the column being initially being made invisible - meeting some criteria will make this item visible. But somehow it is not working. I am sure I am missing something.....help please :)

Code snippent looks something like this..

<telerik:GridButtonColumn UniqueName="BtnAdd" ButtonType="PushButton" CommandName="Add" Text="Add" FooterStyle-CssClass="normalBlueFont" Visible="true"></telerik:GridButtonColumn>
........................................

Code behind

Protected Sub gridException_ItemDataBound(ByVal sender As System.Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridException.ItemDataBound
        DisplayUnmatchedDataInCombo()
 End Sub
    Private Sub DisplayUnmatchedDataInCombo()
        'Code to display the unmatched data in the GridDropDownColumn
        Dim item As GridDataItem
        For Each item In gridException.Items
                If condition = false Then
                    item("BtnAdd").Visible = True
                End If
        Next
    End Sub


Thanks a lot.

Milan G

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 27 Mar 2009, 10:48 AM
Hello Milan,

I recommend you try the following approach:

VB.NET
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound 
    If yourCondition AndAlso TypeOf e.Item Is GridDataItem Then 
        (TryCast(e.Item, GridDataItem))("BtnAdd").FindControl("myAddButton").Visible = True 
    End If 
End Sub 

<telerik:GridTemplateColumn UniqueName="BtnAdd"
    <ItemTemplate> 
        <asp:Button ID="myAddButton" Visible="false" runat="server" CommandName="Add" Text="Add" /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

Let us know whether this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Milan Gurung
Top achievements
Rank 1
answered on 27 Mar 2009, 12:37 PM
Thanks Daniel.

Regards,
Milan G
Tags
Grid
Asked by
Milan Gurung
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Milan Gurung
Top achievements
Rank 1
Share this question
or