hi matt,
I see you are still stuck with classic asp ;P
In asp.net you do not declare code blocks anywhere in your hmtl and perform
evaluations
This is the way to go :
in your codebehind class you need to write your function :
Function DisplayImage(ByVal DtmCompleted As string, ByVal DtmReturnedToInv
As string,ByVal strCode as string) As String
' Do your evaluation here and then return your string
Return "<img style=""width:40px;height:40px;border:0px""
src=""../../images/touchscreen/verify_off.gif"" name=""img" & strcode & """
id=""img" & strcode & """ onclick=""javascript
:selectCustomer('" & strcode &
"');""" & " />"
End Function
then call it in your repeater like this :
<itemtemplate>
<tr>
<td class="tsbody" align="left" valign="middle" bgcolor="#efefef">
<%# DataBinder.Eval(Container.DataItem, "StrDrugDesc") %>
</td>
<td class="tsbody" align="left" valign="middle" bgcolor="#efefef">
<b><%# DataBinder.Eval(Container.DataItem, "PrescriptNo")
%></b>
</td>
<td class="tsbody" align="center" valign="middle" bgcolor="#efefef">
<asp:Literal id="Literal1" text='<%# DisplayImage(DataBinder.Eval(Container,
"DataItem.DtmCompleted"), DataBinder.Eval(Container,
"DataItem.DtmReturnedToInv"), DataBinder.Eval(Container,
"DataItem.StrCode")) %>' runat="server"></asp:Literal>
</td>
</tr>
</itemtemplate>
I have used a literal control here and am supply the return value from your
function to its text value.
"matt" <> wrote in message
news:...
> Since I didn't get any responses yet, maybe I should rephrase the question
> because I think this has to be a common functionality for web developers.
>
> I am trying to show/hide an image in a table column based on a value in
> underlying row's datarow. I am using the asp:Repeater because I am
> displaying hierarchical data and it seemed the easiest to format with.
The
> image, when clicked, needs to fire a clientside javascript function.
>
> I tried creating HtmlImage controls on the fly in the Repeater's
> onitemcreated event. But, I haven't figured out how to get the image
inside
> the column I want because the <TD>'s are not set to runat "server". I
> cannot locate the <TD> in the e.Item.Controls object.
>
> Any Ideas?
>
> Thanks a bunch, I'm really in a crunch now.
>
> "matt" <> wrote in message
> news:%...
> > I wanted to conditionally show an IMG based on values in the Repeater
> > record. Here is the code I am trying to implement...this does not work
> > because it does not like the Container object in this context.
> >
> > <itemtemplate>
> > <tr>
> > <td class="tsbody" align="left" valign="middle" bgcolor="#efefef">
> > <%# DataBinder.Eval(Container.DataItem, "StrDrugDesc") %>
> > </td>
> > <td class="tsbody" align="left" valign="middle" bgcolor="#efefef">
> > <b><%# DataBinder.Eval(Container.DataItem, "PrescriptNo")
> > %></b>
> > </td>
> > <td class="tsbody" align="center" valign="middle" bgcolor="#efefef">
> > <%
> > ' **** PROBLEM HERE ****
> > Dim str as string = DataBinder.Eval(Container.DataItem,
"DtmCompleted")
> > Dim str1 as string = DataBinder.Eval(Container.DataItem,
> > "DtmReturnedToInv")
> >
> > ' Only show if not completed and not returned
> > If (not (str is nothing) and not (str1 is nothing)) Then
> > %>
> > <img width="40" height="40" border="0"
> > src="../../images/touchscreen/verify_off.gif"
> > name="img<%# DataBinder.Eval(Container.DataItem, "StrCode") %>"
> > id="img<%# DataBinder.Eval(Container.DataItem, "StrCode") %>"
> > onclick="javascript:selectCustomer('<%#
> > DataBinder.Eval(Container.DataItem, "StrCode") %>');"
> > <% End If %>
> > />
> > </td>
> > </tr>
> > </itemtemplate>
> >
> >
>
>