0

I want to download a document from the database related to a specific employee by making use of a link button that is found inside a repeater control.The certificate is what I want to download as this is the name of the file inside the database.

This is my code for my repeater control:

<asp:Repeater ID="RepeaterEmployee" runat="server" OnItemCommand="RepeaterEmployee_ItemCommand">            
    <ItemTemplate>
        <table runat="server" class="table table-default table-striped table-bordered table-condensed">
            <tr><td colspan="2" style="text-align:center;" ><asp:Image ID="Image1" runat="server" ImageAlign="Middle"  ImageUrl='<%# Eval("Photo") %>' /></td></tr>
            <tr>
                <td style="vertical-align:middle;">
                    <%--<asp:Image ID="EmployeePhoto" runat="server" ImageAlign="AbsMiddle"  ImageUrl='<%# Eval("Photo") %>' />--%>
                </td>
                <td>
                    <table runat="server" style="width:100%;">
                        <tr>
                            <td><b>First Name:</b></td>
                            <td><asp:Label ID="FirstName" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Last Name:</b></td>
                            <td><asp:Label ID="lblLastName" runat="server" Text='<%#Eval("LastName") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Employee Code:</b></td>
                            <td><asp:Label ID="lblCode" runat="server" Text='<%#Eval("Code") %>'></asp:Label></td>
                        </tr>                                      
                            <td><b>Right Eye Corr Day/Night:</b></td>
                            <td><asp:Label ID="lblRightEyeCorrDayNight" runat="server" Text='<%#Eval("RightEyeCorrDayNight") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Visual Field Left Day/Night:</b></td>
                            <td><asp:Label ID="lblVisualFieldLeftDayNight" runat="server" Text='<%#Eval("VisualFieldLeftDayNight") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Visual Field Right Day/Night:</b></td>
                            <td><asp:Label ID="lblVisualFieldRightDayNight" runat="server" Text='<%#Eval("VisualFieldRightDayNight") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Colour Vision Day/Night:</b></td>
                            <td><asp:Label ID="lblColourVisionDayNight" runat="server" Text='<%#Eval("ColourVisionDayNight") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Date Tested:</b></td>
                            <td><asp:Label ID="lblDateTested" runat="server" Text='<%#Eval("DateTested") %>'></asp:Label></td>
                        </tr>
                        <tr>
                            <td><b>Medical Report:</b></td>
                            <td>
                                 <asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" OnClick="LinkButton1_Click" CommandArgument='<%# Eval("Certificate") %>' CommandName="download">Download</asp:LinkButton>
                            </td>
                        </tr>         
                    </table>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:Repeater>
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87
Tevin
  • 21
  • 6

1 Answers1

0

Instead of the link button create simple anchor tag and bind the document name in the source of the tag while binding the repeater
e.g.-
"
<a> href="/images/myw3schoolsimage.jpg" ID="LinkButton1" runat="server" target="_blank" download>"

use can use the item data-bound event to bind the href(path of the document) of the button.
Please reply me if it is not working

Shyam Sa
  • 331
  • 4
  • 8