Download PDF report from database on LinkButton inside ASP.Net Repeater Click using C# and VB.Net

Last Reply 2 months ago By pandeyism

Posted 2 months ago

how to download Document from database using a Link Button.

            <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>
                                       <tr>
                                        <td><b>ID:</b></td>
                                        <td><asp:Label ID="lblEmployeeID" runat="server" Text='<%#Eval("EmployeeID") %>'></asp:Label></td>
                                    </tr>
                                     <tr>
                                        <td><b>Cost Centre:</b></td>
                                        <td><asp:Label ID="lblCostCentre" runat="server" Text='<%#Eval("CostCentre") %>'></asp:Label></td>
                                    </tr>
                                     <tr>
                                        <td><b>Examination Type Name:</b></td>
                                        <td><asp:Label ID="lblExaminationTypeName" runat="server" Text='<%#Eval("ExaminationTypeName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Physical Examination Name:</b></td>
                                        <td><asp:Label ID="lblPhysicalExamName" runat="server" Text='<%#Eval("PhysicalExamName") %>'></asp:Label></td>
                                    </tr>
                                     <tr>
                                        <td><b>Examination Type Name:</b></td>
                                        <td><asp:Label ID="labelExaminationTypeName" runat="server" Text='<%#Eval("ExaminationTypeName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Audiogram Name:</b></td>
                                        <td><asp:Label ID="lblAudiogramName" runat="server" Text='<%#Eval("AudiogramName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Audiogram Reccomendation:</b></td>
                                        <td><asp:Label ID="lblAudiogramRecName" runat="server" Text='<%#Eval("AudiogramRecName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>LungFunction:</b></td>
                                        <td><asp:Label ID="lblLungFunctionName" runat="server" Text='<%#Eval("LungFunctionName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Chest Results:</b></td>
                                        <td><asp:Label ID="lblChestResults" runat="server" Text='<%#Eval("ChestResults") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>ECG Result:</b></td>
                                        <td><asp:Label ID="lblECGResult" runat="server" Text='<%#Eval("ECGResult") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Blood Glucose Result:</b></td>
                                        <td><asp:Label ID="lblBloodGlucoseResult" runat="server" Text='<%#Eval("BloodGlucoseResult") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>GGT Result:</b></td>
                                        <td><asp:Label ID="lblGGTResult" runat="server" Text='<%#Eval("GGTResult") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Left Eye Day/Night:</b></td>
                                        <td><asp:Label ID="lblLeftEyeDayNight" runat="server" Text='<%#Eval("LeftEyeDayNight") %>'></asp:Label></td>
                                    </tr>
                                     <tr>
                                        <td><b>Right Eye Day/Night:</b></td>
                                        <td><asp:Label ID="lblRightEyeDayNight" runat="server" Text='<%#Eval("RightEyeDayNight") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Left Eye Corr Day/Night:</b></td>
                                        <td><asp:Label ID="lblLeftEyeCorrDayNight" runat="server" Text='<%#Eval("LeftEyeCorrDayNight") %>'></asp:Label></td>
                                    </tr>
                                    <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>Dept Perception Day/Night:</b></td>
                                        <td><asp:Label ID="lblDeptPerceptionDayNight" runat="server" Text='<%#Eval("DeptPerceptionDayNight") %>'></asp:Label></td>
                                    </tr>
                                      <tr>
                                        <td><b>Optometrist Yes/No:</b></td>
                                        <td><asp:Label ID="lblOptometristYesNo" runat="server" Text='<%#Eval("OptometristYesNo") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Exam Outcome:</b></td>
                                        <td><asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Outcome Recommendation:</b></td>
                                        <td><asp:Label ID="lblOutcomeRecommendationsName" runat="server" Text='<%#Eval("OutcomeRecommendationsName") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Other Problems:</b></td>
                                        <td><asp:Label ID="lblOtherProblems" runat="server" Text='<%#Eval("OtherProblems") %>'></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td><b>Notes:</b></td>
                                        <td><asp:Label ID="lblNotes" runat="server" Text='<%#Eval("Notes") %>'></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" OnDataBinding="LinkButton1_DataBinding" OnClick="LinkButton1_Click" CommandArgument='<%# Eval("Certificate") %>' CommandName="download">Download</asp:LinkButton>
                                        </td>
                                    </tr> 
                                </table>
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:Repeater>