protected void Page_Load(object sender, EventArgs e) { if (Application["Predmeti"] != null) { Predmeti p = Application["Predmeti"] as Predmeti; List <string> predmeti = p.PredmetiGlasa.OrderByDescending(v => v.Value).Select(i => i.Key).ToList(); List <int> poeni = p.PredmetiGlasa.Select(v => v.Value).OrderByDescending(v => v).ToList(); lstPredmeti.DataSource = predmeti; lstPoeni.DataSource = poeni; lstPredmeti.DataBind(); lstPoeni.DataBind(); } }
protected void btnGlasajte_Click(object sender, EventArgs e) { if (lstPredmeti.SelectedIndex > -1) { Session["Predmet"] = lstPredmeti.SelectedItem.Text; Application.Lock(); if (Application["Predmeti"] == null) { Application["Predmeti"] = new Predmeti(); } (Application["Predmeti"] as Predmeti).PredmetiGlasa[Session["Predmet"].ToString()]++; Application.UnLock(); HttpCookie cookie = new HttpCookie(Session["Ime"].ToString()); cookie.Expires = DateTime.Now.AddYears(1); cookie.Value = "1"; Response.Cookies.Add(cookie); Response.Redirect("UspesnoGlasanje.aspx"); } }