|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to hide the "Edit" link in DetailsView via code?I need to hide the "Edit" link of a DetailsView control based on a
condition. Basically trying to set the "ShowEditButton" property to "false" when loading the page with the DetailsView on it if the user is not an admin. Is it possible to do via code? The commandfield links are not templated, they're generated. I guess if I use template fields I can control visibility then but can it be done by setting the "ShowEditButton" property of the CommandField in code somehow? >I need to hide the "Edit" link of a DetailsView control based on a In Page_Load, before data binding happens, you may set the ShowEditButton > condition. Basically trying to set the "ShowEditButton" property to > "false" when loading the page with the DetailsView on it if the user > is not an admin. Is it possible to do via code? The commandfield links property appropriately: void Page_Load(...) { if(IsUserAdmin()) { detailsView1.ShowEditButton = true; } else { detailsView1.ShowEditButton = false; } } -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- Sorry but there isn't an accessible "ShowEditButton" property of the
DetailView1 control that I can see. It doesn't even show in the IntellySense. The ShowEditButton property is actually the property of the CommmandField object in the DetailsView control's Field collection as far as I can tell. This is in ASP.Net 2.0 of course. So how can I access this property? Thanks! On Sun, 24 Sep 2006 19:38:08 +0530, "Gaurav Vaish \(www.EduJiniOnline.com\)" <gaurav.vaish.nospam@nospam.gmail.com> wrote: Show quoteHide quote >>I need to hide the "Edit" link of a DetailsView control based on a >> condition. Basically trying to set the "ShowEditButton" property to >> "false" when loading the page with the DetailsView on it if the user >> is not an admin. Is it possible to do via code? The commandfield links > >In Page_Load, before data binding happens, you may set the ShowEditButton >property appropriately: > >void Page_Load(...) >{ > if(IsUserAdmin()) > { > detailsView1.ShowEditButton = true; > } else > { > detailsView1.ShowEditButton = false; > } >} > Sorry but there isn't an accessible "ShowEditButton" property of the Oops! My fault... I was actually referring to the column. Duh!> DetailView1 control that I can see. It doesn't even show in the > IntellySense. The ShowEditButton property is actually the property of > the CommmandField object in the DetailsView control's Field collection > as far as I can tell. This is in ASP.Net 2.0 of course. The property to be worked with for DetailView is DefaultMode -- set it to DetailsViewMode.ReadOnly or DetailsViewMode.Edit. -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- The property to or not auto-generate-edit-button is
AutoGenerateEditButton and not ShowEditButton. Ignore my previous posting. -- Show quoteHide quoteHappy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- "turboJeeper" <turboJee***@aol.com> wrote in message news:22bih29auv23icfov5deaor51rfpm9jpov@4ax.com... > Sorry but there isn't an accessible "ShowEditButton" property of the > DetailView1 control that I can see. It doesn't even show in the > IntellySense. The ShowEditButton property is actually the property of > the CommmandField object in the DetailsView control's Field collection > as far as I can tell. This is in ASP.Net 2.0 of course. > > So how can I access this property? > > Thanks! > > On Sun, 24 Sep 2006 19:38:08 +0530, "Gaurav Vaish > \(www.EduJiniOnline.com\)" <gaurav.vaish.nospam@nospam.gmail.com> > wrote: > >>>I need to hide the "Edit" link of a DetailsView control based on a >>> condition. Basically trying to set the "ShowEditButton" property to >>> "false" when loading the page with the DetailsView on it if the user >>> is not an admin. Is it possible to do via code? The commandfield links >> >>In Page_Load, before data binding happens, you may set the ShowEditButton >>property appropriately: >> >>void Page_Load(...) >>{ >> if(IsUserAdmin()) >> { >> detailsView1.ShowEditButton = true; >> } else >> { >> detailsView1.ShowEditButton = false; >> } >>}
Control events - page life-cycle
White strip showing up between two imagemaps ASP.NET 2.0 / GridView / ObjectDataSource / Update / Missing Columns The parameter is not correct from SqlDataAdapter control ASP code Controls calling other controls problem - ASP.NET 2.0 create webcontrols in aspx or aspx.cs DropDownList SelectedIndexChanged How to keep state of treeview control ASP.Net 2.0 DropDownList Selected Not Working... |
|||||||||||||||||||||||