Click here to Skip to main content
15,919,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

How to display list view control with Condition in asp.net?


I have 3 roles,

Role 1. Admin_Role : All columns are display(no Restriction).
Role 2. Manager_Role : All Columns are Display(Except Only one Column)
Role 3. Employee_Role : Only 5 Columns are Display.

Note:
Only one List View.
How to Possible it.

Give me Solution?

By MOhan>.
Posted

Use RolePrincipal.IsInRole[^]

Refer this Post[^]
 
Share this answer
 
Try following:
Set your Control.Enabled property value according to the function HttpContext.Current.User.IsInRole("ROLE HERE") returned value.

C#
<asp:label id="lblCompany" runat="server" text="<% #Eval("CompanyName")%>" enabled="<%# HttpContext.Current.User.IsInRole("ROLE HERE") %>" xmlns:asp="#unknown"></asp:label>

C#
<asp:textbox id="txtAddress" runat="server" text="<%#Eval("Address")%>" xmlns:asp="#unknown">
Enabled='<%# HttpContext.Current.User.IsInRole("ROLE HERE") %>'></asp:textbox>
 
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