如果列为空,我想向gridview添加一个控件是否可以在asp.net 2.0中使用

时间:2009-07-31 09:22:59

标签: asp.net gridview .net-2.0

我有一个数据网格视图。在填充gridview之前,我想验证列是否为空。如果为null我想将控件添加到gridview。

是否可能

提前致谢

1 个答案:

答案 0 :(得分:1)

你可以在网格rowdatabound事件中做...就像......

protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        System.Data.DataRowView dr = (System.Data.DataRowView)e.Row.DataItem;
        if (string.IsNullOrEmpty(dr["column"].ToString()))
        {
            //add your control or set visibility of ur control
        }
    }
}