I've got an ASP.NET GridView bound to an ObjectDataSource where columns are not automatically generated. Now I want to display one row (containing the link to the edit-page) based on the permission of the user. I've got an method which does all the permission checks and returns a simple boolean value describing the visibility of the row. Now my markup looks somewhat like this:
<Columns>
<%-- Some important information rows --%>
<asp:TemplateField Visible='<%= CanEditRows() %>'>
<%-- Column content --%>
</asp:TemplateField>
</Columns>
However this somehow allways results in an error:
Object of type System.Boolean cannot be created from String '<%= CanEditRows() %>' and assigned to the Visible-property.
(or something in this way...)
I've also tried to toggle the column visibility from code-behind inside the DataBound or DataBinding-Events of the GridView, but everything I tried was unsuccessfull...
Can anybody help me out? :)
Thanks in advance!
try with this code
<asp:TemplateField Visible=<%# CanEditRows() %> >