<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" PageIndex="5" PageSize="5" style="margin-left: 312px; margin-top: 20px;" HorizontalAlign="Justify" onselectedindexchanged="GridView2_SelectedIndexChanged"> <Columns> <asp:BoundField DataField="File_Name" HeaderText="File Name" SortExpression="File_Name" /> <asp:BoundField DataField="Document_Number" HeaderText="Document Number" SortExpression="Document_Number" /> <asp:BoundField DataField="Upload_Date" HeaderText="Uploaded On" SortExpression="UploadDate" /> <asp:BoundField DataField="Upload_User" HeaderText="Uploaded BY" SortExpression="Upload_User" /> <asp:ButtonField ButtonType="Link" CommandName="Dwn" Text="Download" HeaderText="Download Files"/> </Columns> <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> <RowStyle BackColor="White" ForeColor="#003399" /> <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /> <SortedAscendingCellStyle BackColor="#EDF6F6" /> <SortedAscendingHeaderStyle BackColor="#0D4AC4" /> <SortedDescendingCellStyle BackColor="#D6DFDF" /> <SortedDescendingHeaderStyle BackColor="#002876" /> </asp:GridView>
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Dwn") { string path = ("NewFolder1") + "\\" +ddcollege.SelectedValue + "\\" + dddept.SelectedValue + "\\" +ddcategory.SelectedValue + "\\" + ddloctn.SelectedItem + "\\"; int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView2.Rows[index]; string fName = row.Cells[1].Text; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + fName); Response.TransmitFile(Server.MapPath(path+ fName)); Response.End(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)