c# - How to hide a column in a DataGrid? -
i need hide revtodate
column in datagrid
user not admin. how hide column?
<asp:datagrid runat="server" cssclass="tblresults" onitemdatabound="dglist_itemcreated" allowsorting="true" onsortcommand="dgcustomer_sort" id="dgcustomers" datakeyfield="id" autogeneratecolumns="false"> <headerstyle cssclass="tblresultsheader" /> <alternatingitemstyle backcolor="#eeeeee" /> <columns> <asp:hyperlinkcolumn itemstyle-cssclass="loading" datanavigateurlformatstring="customer.aspx?custid={0}" datanavigateurlfield="id" datatextfield="accountcode" headertext="a/c code" sortexpression="accountcode"></asp:hyperlinkcolumn> <asp:boundcolumn datafield="currencydesc" headertext="currency" sortexpression="currencydesc"></asp:boundcolumn> <asp:boundcolumn datafield="revtodate" headertext="rev date (net)" sortexpression="revtodate"></asp:boundcolumn> <asp:boundcolumn datafield="creditlimitamount" headertext="credit limit" sortexpression="creditlimitamount"></asp:boundcolumn> <asp:boundcolumn datafield="discountreviewdate" headertext="discount review date" sortexpression="discountreviewdate" visible="false"></asp:boundcolumn> </columns> </asp:datagrid
i'm using code hide items:
if (!currentuser.isinrole("admin")) { btndelete.visible = false; btnupload2.visible = false; }
but not sure how hide column. can't set visible false in css because hide column users.
you can this.
if (!currentuser.isinrole("admin")) { this.dgcustomers.columns[2].visible = false; btndelete.visible = false; btnupload2.visible = false; }
Comments
Post a Comment