0

Hi say of have a table of cars in my SQL database. That table has a column for the car make and a column called picture of type:

Picture(image, null)

I'm then displaying my cars in a repeater and so it might look like this:

<asp:Repeater id="carsRepeater" runat="server" DataSourceID="CarsDataSource>
  <HeaderTemplate>
    <table>
  </HeaderTemplate>
  <ItemTemplate>
    <tr>
      <td>
        <asp:Label id="carMakeLabel" runat="Server" Text='<%# Eval("Make") %>' />
      </td>
      <td>
        Some how display a clickable image here
      </td>
    </tr>
  </ItemTemplate>
  <FooterTemplate>
    </table>
  </Footer>
</asp:Repeater>

What I'm wanting is in column two to get the picture of the car to display and make it so you can click on that picture and it will run a method in the code behind. Also I have this requirement where the picture click method mustn't require javascript to run.

Can someone please give me an idea of how I would go about this?

I'm currently thinking about putting the image somehow in a link but I'm not sure how to display the image. Maybe the asp:Image but that requires an ImageUrl.

2 Answers 2

1

Try image button, it displays an image, doesn't require javascript and you can run a method on click event from code behind

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but I'm unsure how to set the image to this button given it's not coming from a file location but from sql.
0

Write an HTTPHandler (say CarImage.ashx) and in that handler, given ID of the image return the binary data with ContentType of image/gif (or whatever). Render an image tag in the datagrid with src as CarImage.ashx?ImageID=xxxxx. The process is described many place including this one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.