Thanks a lot Neil.
got there in the end..
<%# ((DataBinder.Eval(Container.DataItem,
"ImageFilename").ToString()=="") ? "" :"<a
href="+DataBinder.Eval(Container.DataItem, "link")+"><img
src='/Images/Products/"+DataBinder.Eval(Container.DataItem,
"ImageFilename")+"' border='0' /></a>")%>
"Neil Woodvine" <(E-Mail Removed)> wrote in message news:<cedr2d$chr$(E-Mail Removed)>...
> Have not used the Repeater before, but for DataBinding statement in DataGrid
> and DataList you need to use the IIF statement for conditional processing.
>
> e.g.
> iif(DataBinder.Eval(Container.DataItem, "ImageFilename") = "", "", "<a href
> .... etc")
>
> Also, note position of first closing parenthesis. You need to resolve the
> DataBinder.Eval statement before testing it against the empty string.
>
> Cheers,
> Neil
>
>
> "az bij" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > I have a dataset bound to a repeater and want to place some logic in
> > my ascx file. I want to display an image link if and only if an image
> > is available.
> >
> > I have tried without success variations of:
> >
> > <%#if(DataBinder.Eval(Container.DataItem,"ImageFilename"!="")){%>
> > <a href="#"><img src=<%#DataBinder.Eval(Container.DataItem,
> > "ImageFilename")%>/></a>
> > <%}%>
> >
> >
> > The above gives: Compiler Error Message: CS1513: } expected
> >
> > Replacing the last <%}%> with <%#}%> gives: CS1525: Invalid expression
> > term 'if'
> > And if I remove the # from the first directive: CS0246: The type or
> > namespace name 'Container' could not be found
> >
> > It's driving me mad. Can anyone help please?
> >
> > Thanks,
> > Andy
|