protected void deletelinkbtn_Click(object sender, EventArgs e) { string id = (sender as LinkButton).CommandArgument; studentdataupload sd = md.studentdatauploads.First(p => p.fId == Convert.ToInt32(id)); System.IO.File.Delete(Server.MapPath("Myfile\\") + sd.fName); md.studentdatauploads.DeleteOnSubmit(sd); md.SubmitChanges(); ScriptManager.RegisterStartupScript(Page, typeof(Page), "popup", "alert('deleted successfully');", true); if (DropDownList1.SelectedItem.Text == "--SelectAll--") { var p = from f in md.studentdatauploads join k in md.TechLists on f.iTechId equals k.iTechId orderby f.fId descending select new { f.fName, f.fDate, f.fId, f.fPath, k.sTechnology }; if (p.Count() <= 0) { // ScriptManager.RegisterStartupScript(Page, typeof(Page), "popup", "alert('Deleted successfully');", true); } else { GridView1.DataSource = p; GridView1.DataBind(); } } else { var p = from f in md.studentdatauploads join k in md.TechLists on f.iTechId equals k.iTechId where k.sTechnology == DropDownList1.SelectedItem.Text orderby f.fId descending select new { f.fName, f.fDate, f.fId, f.fPath, k.sTechnology }; if (p.Count() <= 0) { } else { GridView1.DataSource = p; GridView1.DataBind(); } } }
partial void Deletestudentdataupload(studentdataupload instance);
partial void Updatestudentdataupload(studentdataupload instance);
partial void Insertstudentdataupload(studentdataupload instance);
protected void deletebtn_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (((CheckBox)row.FindControl("CheckBox1")).Checked) { studentdataupload sd = md.studentdatauploads.First(p => p.fId == Convert.ToInt32(((Label)row.FindControl("Label5")).Text)); System.IO.File.Delete(Server.MapPath("Myfile\\") + sd.fName); md.studentdatauploads.DeleteOnSubmit(sd); md.SubmitChanges(); } } if (DropDownList1.SelectedItem.Text == "--SelectAll--") { var p = from f in md.studentdatauploads join k in md.TechLists on f.iTechId equals k.iTechId orderby f.fId descending select new { f.fName, f.fDate, f.fId, f.fPath, k.sTechnology }; if (p.Count() <= 0) { GridView1.Visible = false; //ScriptManager.RegisterStartupScript(Page, typeof(Page), "popup", "alert('No files found.');", true); } else { GridView1.Visible = true; GridView1.DataSource = p; GridView1.DataBind(); } } else { var p = from f in md.studentdatauploads join k in md.TechLists on f.iTechId equals k.iTechId where k.sTechnology == DropDownList1.SelectedItem.Text orderby f.fId descending select new { f.fName, f.fDate, f.fId, f.fPath, k.sTechnology }; if (p.Count() <= 0) { GridView1.Visible = false; } else { GridView1.Visible = true; GridView1.DataSource = p; GridView1.DataBind(); } } }