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 klient_ostukorv : System.Web.UI.Page { private void ImeAndmed() { GridView1.DataSource = Session["ostukorv"] as DataTable; GridView1.DataBind(); } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ImeAndmed(); } } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; ImeAndmed(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; ImeAndmed(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { DataTable ostukorv = Session["ostukorv"] as DataTable; int ToodeID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[0].Text); double Kogus = Convert.ToDouble(((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text); DataRow rida = ostukorv.Rows.Find(ToodeID); rida["Kogus"] = Kogus; Session["ostukorv"] = ostukorv; GridView1.EditIndex = -1; GridView1.DataSource = ostukorv; GridView1.DataBind(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable ostukorv = Session["ostukorv"] as DataTable; int ToodeID = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[0].Text); DataRow rida = ostukorv.Rows.Find(ToodeID); rida.Delete(); Session["ostukorv"] = ostukorv; GridView1.DataSource = ostukorv; GridView1.DataBind(); } }