I have a gridview that gets the data from a database, which works perfect, but in that gridview I also have two links (pictures) which both should open a page with a querystring (like: Page2.aspx?id=23) where the data also comes from the db. The problem is that these pictures should only be displayed when the logged in user is Admin. I can't seem to do it the same way as the hyperlinkfield in the gridview
This is what I have:
<
asp:GridView ID="GridViewProducts" runat="server" AutoGenerateColumns="False" DataKeyNames="ProdID" DataSourceID="SqlDataSourceProducts" EmptyDataText="Der findes ingen produkter i valgte gruppe." AllowPaging="True" AllowSorting="True" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" PageSize="30" cssclass="list">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="ProdID" DataNavigateUrlFormatString="ProductView.aspx?ProdID={0}" DataTextField="Name" HeaderText="Produktnavn" NavigateUrl="~/MemberPages/ProductView.aspx" SortExpression="Name" />
<asp:BoundField DataField="Description" HeaderText="Beskrivelse" SortExpression="Description" />
<asp:TemplateField HeaderText="Stupid link" ShowHeader="False">
<ItemTemplate>
<asp:LoginView ID="loginivew" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="Admin">
<ContentTemplate>
<asp:ImageButton ID="imgDelete" runat="server" ImageUrl="~/Images/DeleteIcon.png" OnClick="imgDelete_Click" />
<asp:HyperLink ID="link" runat="server" NavigateUrl="~/Admin/EditProduct.aspx" ImageUrl="~/Images/EditIcon.png" ></asp:HyperLink>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Is there a better way to do it than how I'm trying to do it?
Notice that I have tried both the imagebutton and hyperlink to do it, but none of them has the option I'm looking for