protected void Button1_Click(object sender, EventArgs e) { string str = string.Format(@"select m.pcode, m.fyyear, m.date, m.FileName FROM upload AS m where m.pcode = '{0}'", DropDownList1.SelectedItem.Value.ToString()); SqlDataAdapter da = new SqlDataAdapter(str, con); DataTable dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); DropDownList1.SelectedIndex = 0; } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Dwn") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; string fName = row.Cells[1].Text; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + fName); Response.TransmitFile(Server.MapPath("~/docs/" + fName)); Response.End(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)