Tuesday, October 23, 2007

changing grid view image acording to the values of grid view (using datakey filed)

protected void gvSalesOrder_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow row in gvSalesOrder.Rows)
{
if (gvSalesOrder.DataKeys[row.DataItemIndex].Values[1].ToString().Trim() == "1" gvSalesOrder.DataKeys[row.DataItemIndex].Values[2].ToString().Trim() == "True")
{
ImageButton b = (ImageButton)row.Cells[5].Controls[0];
if (b != null)
{
b.ImageUrl = "~/Images/icoAddWODisabled.gif";
b.OnClientClick = "return false;";
}
}
}
}

No comments: