Help with this

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am trying to add images to a column based on the result of another column.
I created a template column and using a code-behind function

this is part of my html for the grid

<asp:BoundColumn DataField="status" ReadOnly="True" HeaderText="Status">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Map!">
<HeaderStyle horizontalalign="Center"
verticalalign="Middle"></HeaderStyle>
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<img src='<%#getImage(Container.DataItem("status"))%>'/>
</ItemTemplate>
</asp:TemplateColumn>


This is my function

Protected Function getImage(ByVal dField As Object) As String

Select Case dField

Case "Accepted"

Return "images\approve.png"

Case "Rejected"

Return "images\deny.png"

End Select

End Function

I even tried this in my HTML also but didn't work


<asp:Image id="img" Runat="Server"
ImageUrl='<%#getImage(Container.DataItem("status"))%>'/>

any ideas?
 
Please provide an error message!

....it might be that you in the function, asume that the argument you send
in, is a string. What if you are getting DBNull? Then the Select Case won't
work.

But since you are not providing the error message I might be on the wrong
path here...

Best Regards/
Lars Netzel
 
Bu the way... why are you using Backslash ( Return "images\approve.png"
)? Shouldn't it be a Slash(Return "images/approve.png")

/Lars
 
Did you try View | Source in the browser to see what's actually getting sent
to the client? That's often the quickest way to see what's wrong...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top