Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Security Setup seems to overwrite ReadOnly -propert
Message
From
01/04/2004 12:09:27
 
 
To
01/04/2004 11:50:46
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00890596
Message ID:
00891507
Views:
25
Pertti,

Decalre a public field
public bool ltrue;
Set up security on a mmcontrol that will act as a proxy for your templatecolumn control.
Then add the following code to your Page_load event
private void Page_Load(object sender, System.EventArgs e)
{

// ltrue controls the Enabled property of the 
// datagrids TemplateColumn's Hyperlink
// I use the in-line syntax in the HTML view
// to set ltrue true or false. 
// track with the accesslevel of btnAdd.
// btnAdd is a button on the form but you
// can use any control that has a ControlID property.

   mmSecurityAccessLevel AccessLevel = mmAppBase.SecurityMgr.GetAccessLevel(Session["mmUserSecurity_UserPk"],this.btnAdd.ControlID);
   switch(AccessLevel.ToString())       
   {         
       case "ReadOnly":   
	ltrue=false;
	break;                  
       case "Full":            
	ltrue=true;
	break;
       case "None":            
	ltrue=false;
	break;
      default:            
	ltrue=false;
	break;
  }

}
Use ltrue via inline syntax to control enable attribute of your templatecolumn control:
Below please find HTML view of datagrid:
<mm:mmdatagrid id="grdtxnotes" style="Z-INDEX: 111; LEFT: 18px; POSITION: absolute; TOP: 453px"
runat="server" Font-Names="Arial" Width="85%" Height="53px" BorderColor="#404040" BorderWidth="1px" 
Font-Size="XX-Small" IsPostBack="False" AutoGenerateColumns="False"
BindingSource="txnotes" HorizontalAlign="Left" ControlID="00000000-0000-0000-0000-000000000000" 
SecuritySetup="True" AccessLevel="Full" BackImageUrl="smi/group_bg.gif">
<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Top"></AlternatingItemStyle>
<EditItemStyle Font-Size="14px" Font-Names="Courier New" HorizontalAlign="Left" 
VerticalAlign="Top"></EditItemStyle>
<SelectedItemStyle HorizontalAlign="Left" VerticalAlign="Top"></SelectedItemStyle>
<ItemStyle Font-Size="X-Small" Font-Names="Arial" HorizontalAlign="Left" VerticalAlign="Top"
BackColor="Beige"></ItemStyle>
<HeaderStyle Font-Size="Small" Font-Names="Arial"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Edit">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<asp:HyperLink Runat="server" Text='Edit' Enabled="<%#ltrue%>" NavigateUrl=' 
<%#"TreatmentNotesEdit.aspx?ctxid=" + DataBinder.Eval(Container.DataItem,"ctxid")+ "&custno=" + DataBinder.Eval(Container.DataItem,"cid")%>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="date" ReadOnly="True" HeaderText="Date" DataFormatString="{0:d}">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="hyg" ReadOnly="True" HeaderText="Hyg">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="upper" ReadOnly="True" HeaderText="Upper">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="lower" ReadOnly="True" HeaderText="Lower">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="flash" ReadOnly="True" HeaderText="Flash">
<HeaderStyle Width="10%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="treatment" ReadOnly="True" HeaderText="Treatment">
<HeaderStyle Width="45%"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
</Columns>
</mm:mmdatagrid>
Regards,
Dr. G. (Neil)


>Neil:
>
>YOU WROTE: Do you want to have security for an entire column or individual rows of a specific column. I recently had to secure a column in a grid that contained a hyperlink. The entire column of hyperlinks was either enabled or not as per security. If this is what you need I will go back and dig up the code. It involves creating a hyperlink templatecolumn and then setting attributes for the column depending on security settings. Next week I will actually be working on a grid that needs to have specific rows of a column secured. If this is what you need I could share that also. Talk to you soon. BTW I use role-based security exclusively. I have not done this for user-based security.
>
>I would appreciate any code you might have that has to do with grid security. The hyperlink column example would be great, as would the (future) code for specific column(s).
>
>I, too, use role-based security only. This was a syntactical spelling error...
>
>
>Thanks for your help!
>
>Pertti
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform