public static List <Ucenik> PreuzmiUcenike() { List <Ucenik> ucenici = new List <Ucenik>(); using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("~/ucenici.txt"))) { try { string line = sr.ReadLine(); while (!string.IsNullOrEmpty(line)) { Ucenik ucenik = new Ucenik(line); ucenici.Add(ucenik); line = sr.ReadLine(); } } catch (Exception ex) { Console.WriteLine(ex); } } return(ucenici); }
protected void btnDodaj_Click(object sender, EventArgs e) { string line = txtIme.Text + "|" + txtPrezime.Text + "|" + txtRazred.Text; Ucenik.DodajUcenika(line); }
protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = Ucenik.PreuzmiUcenike(); GridView1.DataBind(); }