我有一个数据网格视图。在填充gridview之前,我想验证列是否为空。如果为null我想将控件添加到gridview。
是否可能
提前致谢
答案 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
}
}
}