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

[Solved] Hide RadGrid Column using <% %>

1 Answer 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT Support
Top achievements
Rank 1
IT Support asked on 09 Dec 2009, 10:50 AM
Hi,

I have the following code in the RadGrid of my UserControl:

<telerik:GridTemplateColumn UniqueName="MyColumnName" HeaderText="MyColumnName" Visible='<%# (Mode == SearchAndSelectMode.DataMode) ? true : false %>'
    <ItemTemplate> 
        <asp:ImageButton ID="MyButton" runat="server" ImageUrl="../App_Themes/eventIS/Grid/MyButton.gif" CommandName="DoSomething" /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

The "Mode" property is a public property of my UserControl, and I want to display this column depending on the value of that property. But when I run it, the following error appears:

Databinding expressions are only supported on objects that have a DataBinding event. Telerik.Web.UI.GridTemplateColumn does not have a DataBinding event.

I know it is also possible to hide the columns in code behind, but I want to do it in the ascx because then it is more clear what happens in my opinion. Is there any way to achieve what I want with the RadGrid?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Dec 2009, 11:38 AM
Hello Raymond,

DataBinding expression can be used only with ASP.NET Controls and it is not possible to set the properties for RadGrid Columns using DataBinding Expressions. But probably you can try setting the visibility for the ImageButton using the same expression.

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