Arrao4u

…a blog by Rama Rao

Archive for the ‘Gridview Rowdatabound for displaying images’ Category

Gridview row databound for displaying images

Posted by arrao4u on February 22, 2010

if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView dr = (DataRowView)e.Row.DataItem;
//Use:: if(!string.IsNullOrEmpty(dr[“Status”].ToString()))
if (dr[“Status”].ToString() != “”)
{
// hdnStatus.Value = dr[“Status”].ToString().Trim();
Label lblStValue = (Label)(e.Row.FindControl(“lblStatus”));
lblStValue.Text = dr[“Status”].ToString().Trim(); ;
if ((dr[“Status”].ToString().ToLower().Trim() == “n”) || (dr[“Status”].ToString().ToLower().Trim() == “u”))
{
((ImageButton)(e.Row.FindControl(“imgStatus”))).ImageUrl = “~/images/active.gif”;
((ImageButton)(e.Row.FindControl(“imgStatus”))).ToolTip = “Active”;
}
else
{
((ImageButton)(e.Row.FindControl(“imgStatus”))).ImageUrl = “~/images/inactive.gif”;
((ImageButton)(e.Row.FindControl(“imgStatus”))).ToolTip = “Inactive”;

}
}
}

Posted in Gridview Rowdatabound for displaying images | Leave a Comment »