如何设置ListView列的可见性 [英] How to set listview column's visiblity
本文介绍了如何设置ListView列的可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何在Web应用程序中使用c#动态地将列表视图列的visible属性设置为false.请帮助我.
解决方案
尝试使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.
这篇关于如何设置ListView列的可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文