c# - Hiding fields in DetailsView from codebehind -


sorry if elementary, i'm new .net , have looked around, maybe i'm not searching right terms.

i have detailsview loaded in design view. i'd of these fields show users. thinking in codebehind, hide other fields. i'd change headertext of these fields in codebehind.

however, need detailsview editable. if fields hidden users, wasn't sure how effect anything. update fields, hidden ones?

only users should see edit button well.

does have tips on how go this?

in page class create boolean field represent whether control should visible , set value in page_load. (note: authentication.isauthorized example of how determine field, replace own code)

public partial class mypage : system.web.ui.page {     protected bool showfield = false;     protected void page_load(object sender, eventargs e)     {         showfield = authentication.isauthorized(user.identity.name);     } } 

now bind field in control. note requires use of template fields rather bound fields.

<asp:label id="lblhiddenfield" runat="server" visible='<%# showfield %>' /> 

this work buttons provided they're in template field. i've used bound fields in past , nasty foreach loops find controls want hide, more straight-forward way imho.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -