如果数据源有某一列,而在绑定到GridView时不显示该列,编程时要用到该列的值可以用以下方法:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView dr = (DataRowView)e.Row.DataItem;
            if (dr["btype"].ToString() == "1")
                e.Row.ForeColor = System.Drawing.Color.Red;
        }
    }

 

posted on 2014-06-12 20:39  努力实现目标  阅读(3781)  评论(0编辑  收藏  举报