如何在devexpress gridview动态中删除GridViewDataTextColumn?

时间:2016-08-26 19:28:15

标签: c# asp.net devexpress

如何在devexpress gridview dynamic中删除GridViewDataTextColumn?

DevExpress.Web.GridViewDataTextColumn col1 = new DevExpress.Web.GridViewDataTextColumn() { FieldName = "col1", VisibleIndex = 16 };
DevExpress.Web.GridViewDataTextColumn col2 = new DevExpress.Web.GridViewDataTextColumn() { FieldName = "col2", VisibleIndex = 17 };

if (has)
{
    grd1.Columns.Add(col1);
    grd1.Columns.Add(col2);
    grd1.DataBind();
}
else if (grd1.Columns.IndexOf(grd1.Columns["col1"]) != -1 && grd1.Columns.IndexOf(grd1.Columns["col2"]) != -1)
{
    grd1.DataSource = null;
    grd1.DataBind();
    grd1.Columns.Remove(col1);
    grd1.Columns.Remove(col2);
    grd1.DataBind();
}

0 个答案:

没有答案