如果数据源有某一列,而在绑定到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;
        }
    }

 

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案