
正文
GridView通过RowDataBound事件获取字段值、数据源列值
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
如果数据源有某一列,而在绑定到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() == "")
e.Row.ForeColor = System.Drawing.Color.Red;
}
}








