更新时间:2022-12-26 13:10:39
尝试使Cell的可见性为假.
为此,首先使用FindControl方法查找该行.HtmlTableRow htrRow = e.Item.FindControl(" ); 如果(htrRow!= 空) { htrRow.Cells [ 0 ].Visible = false ; }
为ListView中的tr提供一个ID,因为我为ItemTemplates中的行指定了"rowId",< 表格 > ; < tbody > < tr id =" runat 服务器" < /tr > < /tbody > < /table >
好像您应该能够将标签的Visible属性与ItemTemplate中的Eval("thiscolumnvisible")绑定在一起.或者,将客户端ID放在该列中的项目上,并使用Javascript显示/隐藏它们.
您始终可以将列的宽度更改为0.
How we can set list view columns visible property to false in web applications using c# dynamically. Please help me.
Try to make Cell''s visibility false.
For this first find the row with the help of FindControl method.HtmlTableRow htrRow = e.Item.FindControl("rowId"); if(htrRow != null) { htrRow.Cells[0].Visible = false; }
Provide an ID to the tr in the ListView as I have given "rowId" for the rows in the ItemTemplates,<table><tbody><tr id="rowId" runat="server"> </tr></tbody></table>
Looks like you should just be able to bind the label''s Visible property with Eval("thiscolumnvisible") in the ItemTemplate. Alternatively, put a client side id on the items in that column and use Javascript to show/hide them all.
You could always change the column''s width to 0.