In aspx page :
<asp:ImageButton ID="imgbtn" runat="server" ImageUrl='<%#GetImage(Eval("TemplateID")) %>' CommandArgument='<%#Eval("TemplateID")%>' AlternateText="" />
In code behind :
protected string GetImage(object objGrid)
{
if ((int)(objGrid)==1)
{
return @"\images\ImgPPM.jpg";
}
else if ((int)(objGrid) == 2)
{
return @"\images\ImgBuild.jpg";
}
else if ((int)(objGrid) == 3)
{
return @"\images\ImgDelivery.jpg";
}
else
{
return objGrid.ToString();
}
}
<asp:ImageButton ID="imgbtn" runat="server" ImageUrl='<%#GetImage(Eval("TemplateID")) %>' CommandArgument='<%#Eval("TemplateID")%>' AlternateText="" />
In code behind :
protected string GetImage(object objGrid)
{
if ((int)(objGrid)==1)
{
return @"\images\ImgPPM.jpg";
}
else if ((int)(objGrid) == 2)
{
return @"\images\ImgBuild.jpg";
}
else if ((int)(objGrid) == 3)
{
return @"\images\ImgDelivery.jpg";
}
else
{
return objGrid.ToString();
}
}
No comments:
Post a Comment