Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two role for my system.For both i am using the same page.I created UserControl for that.
For admin
I want to display edit or delete link in template field.
For Teacher
I want to display only edit link.

In aspx.cs page
How to find Template field and how to make visible false to it without using column number for teacher?
Posted
Updated 10-Apr-12 2:52am
v2

1 solution

You can always bind the Visible property to a method on your .cs file.

But you can also use inline code like this:
XML
<%
if (IsVisible())
{%>
   <asp:LinkButton ID="mylink" Text="Your link text"runat="server"> </asp:LinkButton>
<% }%>



You can condition the rendering of any asp.net or html code based on the logic on that IsVisible function. That could be implemented like this:

C#
protected bool IsVisible()
{
     return Roles.IsUserInRole("admin");
}


You replace the function with the final code, in this case because is a simple return line, but well, that will depend on your back-end code.

Hope it helps.
 
Share this answer
 

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