如何隐藏数据表的DataRow? [英] How to hide the DataRow of a datatable?
本文介绍了如何隐藏数据表的DataRow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何隐藏数据表中特定DataRow中的数据行/数据行单元.
Hi,
How can we hide the datarow/ cells of datarow in specific DataRow in datatable.
推荐答案
Hello,
您可以按如下所示在其数据绑定事件中将隐藏在网格视图控件中的行设置为:
Hello,
you can set the row hidden in the grid view control in its databound event as follows:
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(conditionToHideRow== true)
{
e.Row.Style.Add("visibility", "hidden");
e.Row.Style.Add("display", "none");
}
}
}
Gridview有一个名为"RowDataBound"的事件.您可以在该事件中添加以下代码
The Gridview has an event named "RowDataBound". You can add following code in that event
e.Row.Cells[0].Visible=false;
dt.Rows.Remove(row)
它将从数据表dt
It will remove the row from your datatable dt
这篇关于如何隐藏数据表的DataRow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文