Thursday, October 18, 2007

Get the Datakey value from gridview ang change the image acordig to the Data key

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/icoAddWODdisabled.gif";
b.OnClientClick = "return false;";
}
}
}

No comments: