วันศุกร์ที่ 3 มิถุนายน พ.ศ. 2554

ตัวอย่างวิธีการใช้งาน function : DataBinder.Eval in Gridview

void productsGridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// determine the value of the UnitsInStock field
int unitsInStock =
Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
"UnitsInStock"));
if (unitsInStock == 0)
// color the background of the row yellow
e.Row.BackColor = Color.Yellow;
}
}