protected void Page_Load(object sender, EventArgs e) { //PasswordHelper.keneroiKayttaja("Musti", "Musti", "Musti"); filePath = MapPath( ConfigurationManager.AppSettings["xmlHarjoitukset"]); tXmlParser = new TrainingXml(filePath); if (!IsPostBack) { dt = tXmlParser.readXml(); Session["DataTable"] = dt; harkat = tXmlParser.haeHarkat(); BindData(harkat); } initMyStuff(); XMLView.Visible = true; }
protected void saveBtn_Click(object sender, EventArgs e) { Training harkka = new Training(); harkka.name = txtName.Text; harkka.date = txtDate.Text; harkka.time = txtTime.Text; harkka.kilometers = txtKilometers.Text; TrainingXml tXml = new TrainingXml(filePath); //tXml.insertToXml(filePath, dt, harkka); if (Session["DataTable"] != null) { dt = (DataTable)Session["DataTable"]; tXml.insertToXml(filePath, dt, harkka); } else { dt = tXml.readXml(); tXml.insertToXml(filePath, dt, harkka); } }