In aspview gridview, how to access the BoundField in the RowDataBound event?

How do I access the "BoundField" value in the RowDataBound gridview event?

+5
source share
2 answers
DataRowView drv = (DataRowView)e.Row.DataItem; 
if (e.Row.RowType == DataControlRowType.DataRow) 
{ 
if (drv["MYCOLNAME"] != DBNull.Value)
{
  var val = Convert.ToBoolean(drv["MYCOLNAME"]);
} 
}

Just convert to the correct type.

+8
source

BoundField is indicated by column wise in GridView, so basically RowDataBoundit doesn't matter here;).

it can be accessed through

 GridView.Columns;

as

 BoundField b = myGridView.Columns[columnindex] as BoundField;
+2
source

All Articles