Click here to Skip to main content
15,891,019 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My DataGrid is something like this:

ASP.NET
<pre><asp:DataGrid ID="tasks" runat="server" AutoGenerateColumns="False" GridLines="None">
    <HeaderStyle CssClass="task-list-header"/>
    <ItemStyle  CssClass="task-list-row"/>
    <Columns>
        <asp:BoundColumn DataField="Name"
                         HeaderStyle-Width="100px"
                         HeaderText="Name"></asp:BoundColumn>
        <asp:BoundColumn DataField="Description"
                         HeaderStyle-Width="250px"
                         HeaderText="Description"></asp:BoundColumn>
        <asp:BoundColumn DataField="IsComplete"
                         HeaderStyle-Width="125px"
                         HeaderText="Is Complete"></asp:BoundColumn>
        <asp:TemplateColumn>
            <HeaderStyle Width="75px"/>
            <ItemTemplate>
                <asp:HyperLink ID="Hyperlink1" runat="server"
                    NavigateUrl='<%# ModuleContext.EditUrl("TaskId", Eval("TaskId").ToString(), "EditTask") %>'
                    Text="Edit"></asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateColumn>
        <asp:TemplateColumn>
            <HeaderStyle Width="75px"/>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server"
                    CommandArgument='<%# Eval("TaskId") %>' CommandName="Delete" Text="Delete"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateColumn>
    </Columns>
</asp:DataGrid>


This is basically a list of Task with Last 2 columns as Edit and Delete. I am using DNN8. I want to hide the Edit and Delete links if the user is not logged in as Superuser. How can I do that?

What I have tried:

I tried the property using the OnAutoBinding attribute and defining a function in the code behind but I didn't go any further. Thanks for the hwlp.
Posted
Updated 9-Mar-17 19:28pm
v2

1 solution

bool isSuperUser = checkIsSuperUser();
if (!isSuperUser)
{
    tasks.Columns[3].Visible = false; // edit column index
    tasks.Columns[4].Visible = false; // delete column index
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900