Display grid view image based on another column value

  • I want to display image based on another templatefield value.

    Example person num(0010200) and image saved in folder is 00102000.jpg , if person num(01234) and image saved in folder is 01234.jpg, etc. like this i have many employee images.and this all saved in /img/ webfolder.

    Now when ever lable2 person num changes i need to change the image1 which will be same as person num,

    please suggest me to achieve the same. example code below.

    <asp:TemplateField HeaderText="person_num" SortExpression="person_num">

    <ItemTemplate>

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("person_num") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="full_name" HeaderText="full_name" SortExpression="full_name" />

    <asp:TemplateField HeaderText="Image">

    <ItemTemplate>

    <asp:Image id="Image1" runat="server" ImageUrl='<%# Bind("person_num") %>'match as "img/(0)"/>

    </ItemTemplate>

    </asp:TemplateField>

  • philand3 (9/18/2016)


    I want to display image based on another templatefield value.

    Example person num(0010200) and image saved in folder is 00102000.jpg , if person num(01234) and image saved in folder is 01234.jpg, etc. like this i have many employee images.and this all saved in /img/ webfolder.

    Now when ever lable2 person num changes i need to change the image1 which will be same as person num,

    please suggest me to achieve the same. example code below.

    <asp:TemplateField HeaderText="person_num" SortExpression="person_num">

    <ItemTemplate>

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("person_num") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="full_name" HeaderText="full_name" SortExpression="full_name" />

    <asp:TemplateField HeaderText="Image">

    <ItemTemplate>

    <asp:Image id="Image1" runat="server" ImageUrl='<%# Bind("person_num") %>'match as "img/(0)"/>

    </ItemTemplate>

    </asp:TemplateField>

    Note that this is a SQL Server forum.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply