Results 1 to 5 of 5

Thread: datagrid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    datagrid

    Hi,
    In a datagrid on the web form using C#, I would like to have a column which retrieves a picture based on the GetImage function that I have created and then I would like this to be a hyperlink so that when you click it it uses the value of the first column.
    This is what I have using itemtemplate. It retrieves the image but I do not know how to make this image into a hyperlink.
    Thanks

    <asp:TemplateColumn HeaderText="US">
    <ItemTemplate>
    <asp:Image Runat="server" ImageUrl='<%# GetImage(DataBinder.Eval(Container,"DataItem.Status").ToString()) %>'></asp:Image>
    </ItemTemplate>
    </asp:TemplateColumn>

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You should just be able to wrap the asp:Image tag in an asp:Hyperlink tag.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    Hi,
    I tried what you suggested as below and the error is:
    Parser Error: Type 'System.Web.UI.WebControls.HyperLinkColumn' does not have a property named 'asp:Image'.

    May be what I did is incorrect. Please see below:

    <asp:HyperLinkColumn Text="view" DataNavigateUrlField="ImportDate" DataNavigateUrlFormatString="statusSearch.aspx?ImportDate={0}" HeaderText="Details">
    <asp:Image Runat="server" ImageUrl='<%# GetImage(DataBinder.Eval(Container,"DataItem.Status").ToString()) %>' ID="Image1"></asp:Image>
    </asp:HyperLinkColumn>

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Not HyperlinkColumn, Hyperlink.

    I don't know offhand if Hyperlink is the exact type name for the tag, but you should be able to see it in the toolbox.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    or you could use an imagebutton for the column setting it's image as above and then you could set it's commandArgument to the value of the first column and then redirect in code using response.redirect depending on the value of the commandArg.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width