本文介绍了如何在GridView中隐藏TemplateField列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何在GridView中隐藏TemplateField列 我的cose in markup: < asp:TemplateField ShowHeader =' <% #CheckStatus(绑定( 状态))%>' > < / asp:TemplateField > behinde: public static bool CheckStatus( object Status) { if (Status.ToString()== 4) return false ; else return true ; } i尝试上面的代码但得到错误: 数据绑定表达式是仅支持具有DataBinding 事件的对象。 System.Web.UI.WebControls.TemplateField没有DataBinding 事件。 谢谢解决方案 尝试: GridView1.Columns [ 1 ]。可见= false ; protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e) { if(e.Row .RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { e.Row.Cells [2] .Visible = false; //这是你的模板字段列。 } } 您好,请看这个链接: http:// stackoverflow.com/questions/4954871/how-to-hide-a-templatefield-column-in-a-gridview [ ^ ] Hope它有助于! :) hi,How can I hide a TemplateField column in a GridViewmy cose in markup:<asp:TemplateField ShowHeader='<%# CheckStatus(Bind("Status")) %>' ></asp:TemplateField> in code behinde:public static bool CheckStatus(object Status) { if (Status.ToString() == "4") return false; else return true; }i try above code but get error:Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.TemplateField does not have a DataBinding event.thanks 解决方案 Try:GridView1.Columns[1].Visible = false; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[2].Visible = false;//this is your templatefield column. }}Hi, please see this link:http://stackoverflow.com/questions/4954871/how-to-hide-a-templatefield-column-in-a-gridview[^]Hope it helps! :) 这篇关于如何在GridView中隐藏TemplateField列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 08:18