close

一樣也是在GridView中隱藏欄位標題及欄位值,並可之後有需求時抓取所隱藏欄位裡的資料

aspx.cs

 

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        //隱藏標題列中某特定欄位及該隱藏特定欄位整列
        // 1
        GridView1.Columns[2].Visible = false;
        // 2
        foreach (DataControlField col in GridView1.Columns)
        {
            if (col.HeaderText == "標題文字3")
            {
                col.Visible = false;
            }
        }
        // 3(using System.Linq;)        

         ((DataControlField)GridView1.Columns.Cast().Where(s => s.HeaderText == "標題文字3")
               .SingleOrDefault()).Visible = false;




    }
arrow
arrow

    奶茶妹妹 發表在 痞客邦 留言(0) 人氣()