ImageUrl='<%# DetectImagePath(Eval("image_file_name")) %>'
(I don't use eval, not sure if that's correct syntax)
then in code behind:
protected string DetectImagePath(object filename)
{
string sFileName = (string) filename;
if(File.Exists(String.Format("~/images/categories/{0}", sFileName))
return String.Format("~/images/categories/{0}", sFileName);
else if(File.Exists(String.Format("~/images/products/{0}", sFileName))
return String.Format("~/images/products/{0}", sFileName);
else
return "";
}
"trint" <tr***********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I have this in my aspx file (using c#):
<asp:ImageButton ID="Imagebutton1" runat="server" alt='<%# Eval
( "name" ) %>' CommandName="select"
ImageUrl='<%#
Eval ( "image_file_name", "~/images/categories/{0}" ) %>' Width="50%" /
>>
Sometimes the folder of the default image will be in /images/products
and not in /images/categories.
Is there a way to change this in my c# file under certain conditions?
Thanks,
Trint