根据gridview中的标签值隐藏列 [英] Hide column based on label value in gridview
本文介绍了根据gridview中的标签值隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有13列gridview,其中一列有3个值ex1ex2ex3
i想要ex1 apppear隐藏一些列,如果ex2出现隐藏其他列等等on
i尝试使用行环形交叉口,但工作没有任何隐藏
我尝试过什么:
i have gridview with 12 column and one of the column have 3 value "ex1" "ex2" "ex3"
i want if ex1 apppear hide some columns , if ex2 appear hide others columns and so on
i try using row roundabout but dint work nothing is hiding
What I have tried:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = e.Row.FindControl("Label1") as Label;
for (int i = 0; i < GridView1.Columns.Count; i++)
{
if (lbl.Text == "Client")
{
GridView1.Columns[13].Visible = false;
}
}
}
}
推荐答案
if(e.Row.RowType == DataControlRowType.DataRow)
{
int index = GetColumnIndexByName(e.Row, myDataField);
GridView1.Columns [index] .Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
int index = GetColumnIndexByName(e.Row, "myDataField");
GridView1.Columns[index].Visible = false;
}
这篇关于根据gridview中的标签值隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文