protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Book1.xlsx;Extended Properties=Excel 8.0;"; DataTable ds = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter("Select * from[Sheet1$]", strConn); da.Fill(ds); grvPatient.DataSource = ds; grvPatient.DataBind(); } } string PatientId = ""; protected void btn_save(object sender, EventArgs e) { for (int i = 0; i < grvPatient.Rows.Count; i++) { bool chk = ((CheckBox)grvPatient.Rows[i].FindControl("myCheckBox")).Checked; if (chk == true) { PatientId = grvPatient.Rows[i].Cells[1].Text; string Patient = grvPatient.Rows[i].Cells[2].Text; string Amount = grvPatient.Rows[i].Cells[3].Text; string Doctor = grvPatient.Rows[i].Cells[4].Text; string status = grvPatient.Rows[i].Cells[5].Text; dbquery.InsertChecked(Int32.Parse(PatientId), Patient, Int32.Parse(Amount), Doctor); dbquery.deleteRecord(Int32.Parse(PatientId)); //update the status to MS Excel String strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\Book1.xlsx;Extended Properties=Excel 8.0;"; DataTable ds = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter("Select * from[Sheet1$]", strConn); da.Fill(ds); grvPatient.DataSource = ds; grvPatient.DataBind(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)