2

I have a TemplateColumn in my telerik radgird like below :

<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn_Commands column"
                                HeaderText="Commands" UniqueName="TemplateColumn_Commands"
                                AllowFiltering="False" Display="False">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete" CausesValidation="False"
                                        CssClass="lb">Delete</asp:LinkButton>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                            </telerik:GridTemplateColumn>

i want to change display(or visible) property of this column server-side.
which event should i use and how can i do that?
Edit:
there is a button and a textbox and after click on that bottun i checked that text box text and if it be ok i want to change that display(or visible) property of that column(delete acction should be available only for admin with administrator username string) that button is outside of that grid.

thanks in advance

SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • There are many times when that property can change. OnItemCommand, OnItemCreated, OnItemDataBound, OnNeedDataSource. Can you give more details on your specific scenario? – Glenn Ferrie Jun 29 '12 at 11:17
  • Also, please be aware of the difference between 'Display' and 'Visible'... http://www.telerik.com/community/forums/aspnet-ajax/grid/visible-vs-display-on-grid-column-definition.aspx – Glenn Ferrie Jun 29 '12 at 11:19
  • hi, there is a button and a textbox and after click on that bottun i checked that text box text and if it be ok i want to change that display property of that column(delete acction should be available only for admin with administrator username string) – SilverLight Jun 29 '12 at 11:24
  • If the button is part of the row, I would use ItemCommand. If the button is not in the grid I would suggest OnNeedDataSource – Glenn Ferrie Jun 29 '12 at 11:25
  • @GlennFerrieLive i think i should use visible instead of display. thanks for that link. – SilverLight Jun 29 '12 at 11:27
  • that button in outside of that grid. – SilverLight Jun 29 '12 at 11:28
  • @Downvoter -> is my q clear now? so sorry for the loss of information. – SilverLight Jun 29 '12 at 11:35
  • hello -> GlennFerrieLive where are you? – SilverLight Jun 29 '12 at 11:55

1 Answers1

2

you can do it like below. after binding telerik rad grid in server side code

grdDemo.DataSource = ds
grdDemo.DataBind()

grdDemo.MasterTableView.GetColumn("TemplateColumn_Commands").Display = False

it should resolve your issue. happy coding

Prakash Patani
  • 547
  • 4
  • 8
  • i test your codes in itemDataBound event -> for visible property -> does not work. – SilverLight Jun 29 '12 at 11:37
  • you dont need to place this code in any events. its works as beyond to event. just need to check in which condition you need to change the display property. if is there any condition under you want to change property please write "grdDemo.MasterTableView.GetColumn("TemplateColumn_Commands").Display = False" under the condition as per your need. – Prakash Patani Jun 29 '12 at 11:57