using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void gwTooted_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.ToLower() == "osta") { DataTable ostukorv; if (Session["ostukorv"] == null) { ostukorv = new DataTable(); ostukorv.Columns.Add("ToodeID", typeof(int)); ostukorv.PrimaryKey = new DataColumn[] {ostukorv.Columns["ToodeID"]}; ostukorv.Columns.Add("Kogus", typeof(double)); ostukorv.Columns["Kogus"].DefaultValue = 1; } else { ostukorv = Session["ostukorv"] as DataTable; } int ToodeID = Convert.ToInt32(e.CommandArgument); DataRow rida = ostukorv.Rows.Find(ToodeID); if ( rida == null) { rida = ostukorv.NewRow(); rida["ToodeID"] = Convert.ToInt32(e.CommandArgument); ostukorv.Rows.Add(rida); } else { rida["kogus"] = Convert.ToInt32(rida["kogus"]) + 1; } Session["ostukorv"] = ostukorv; Response.Redirect("~/klient/ostukorv.aspx"); } } }