<asp:GridView ID="GridOracle" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="DIS_CHAPTER_ID" OnSelectedIndexChanged="GridOracle_SelectedIndexChanged" BackColor="#CCCCCC" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black"> <%-- BorderColor=#999999--%> <Columns> <asp:BoundField DataField="SEC_NAME" HeaderText="Section Name" ReadOnly="True" ItemStyle-HorizontalAlign="Left" ItemStyle-Font-Bold="true" ItemStyle-VerticalAlign="Middle"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Font-Bold="True"></ItemStyle> </asp:BoundField> <asp:BoundField DataField="CHAPTER_NAME" HeaderText="CourseName" ReadOnly="True" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Middle"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle> </asp:BoundField> <asp:BoundField DataField="Duration" HeaderText="Duration" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Middle"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle> </asp:BoundField> <asp:CommandField CausesValidation="False" InsertVisible="False" ShowCancelButton="False" ButtonType="Image" ShowSelectButton="True" HeaderText="Material" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" SelectImageUrl="~/Content/Images/PDFLogo.png"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle> </asp:CommandField> <asp:CommandField CausesValidation="False" InsertVisible="False" ShowCancelButton="False" ButtonType="Image" ShowSelectButton="True" HeaderText="Material1" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" SelectImageUrl="~/Content/Images/PDFLogo.png"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle> </asp:CommandField> </Columns> <FooterStyle BackColor="#CCCCCC" /> <HeaderStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="Black" /> <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" /> <RowStyle BackColor="White" /> <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F1F1F1" /> <SortedAscendingHeaderStyle BackColor="#808080" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#383838" /> </asp:GridView>
protected void GridOracle_SelectedIndexChanged(object sender, EventArgs e) { try { if (GridOracle.SelectedIndex > -1) { this.Id = Convert.ToInt32(GridOracle.DataKeys[GridOracle.SelectedIndex].Value); string _FName = "select FILE_NAME from OM_DOC_ALL where DIS_CHAPTER_ID = " + Id; string _FileName = (string)SqlHelper.ExecuteScalar(strConn, CommandType.Text, _FName); string FileName = "~/Downloads/OracleMaterial/" + _FileName + ".pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName); WebClient client = new WebClient(); string pdfPath = Server.MapPath("../Downloads/OracleMaterial/" + _FileName + ".pdf"); Byte[] buffer = client.DownloadData(pdfPath); BinaryWriter bw = new BinaryWriter(Response.OutputStream); bw.Write(buffer); bw.Close(); Response.ContentType = "application/pdf"; Response.Flush(); Response.Close(); } else { //Clear Controls } } catch (Exception ex) { ErrorHandling.ErrorLog("PageLoad: ExploreJobs.aspx.cs , Error : " + ex.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)