|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How Do I Conditionally Remove An EditCommandColumn?Hi,
I have a DataGrid control that "by default" comes up with an EditCommandColumn. However, I don't want all users to see this. How do I conditionally remove the EditCommandColumn? Thanks in advance for your help. In Page_Load (or somewhere similar) do this:
if (!User.IsInRole("TheRoleYouCareAbout")) { grid.Columns[TheColumnIndexYouCareAbout].Visible = false; } -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi, > > I have a DataGrid control that "by default" comes up with an > EditCommandColumn. However, I don't want all users to see this. How > do I conditionally remove the EditCommandColumn? Thanks in advance > for your help. > Thanks, but the problem is that an index of 0 is the first "real"
column, not the EditCommandColumn. > Thanks, but the problem is that an index of 0 is the first "real" Hmm, I'd have to go look into why this is. But for a quick alternative answer, > column, not the EditCommandColumn. you can always create your own TemplateColumn, add the <asp:Button runat=server CommandName="Edit" ... /> and then dynamically set it Visible=false. -Brock DevelopMentor http://staff.develop.com/ballen Brock,
Thank you very much for your help. My statement about 0 being the index of the first "real" column was based on the fact that I was indexing off of a DataColumnCollection instead of the DataGrid itself! I believe that I'm all set now by doing just what you originally said. Again, thank you very much!
ASP.NET - How to bind() a dataset to a datagrid using javascript from the client
Pop-up Message Box binding ArrayLists to DataGrids-- how to name the columns? Newbie: Datagrid Comes Up Blank?!? Subclassing a DataGrid control HOWTO: Bring that row back into focus ... Two questions: datagrid with string[] and how to differentiate between columns trying to display header only Wrong window gets the content using datagrid |
|||||||||||||||||||||||