using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { getProductData(); } } private void BindData(DataSet ds) { GridView1.DataSource = ds; GridView1.DataBind(); } private void getProductData() { CustomerBal obj = new CustomerBal(); DataSet ds = new DataSet(); ds = obj.getProductData(); BindData(ds); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; CustomerBal obj = new CustomerBal(); DataSet ds = new DataSet(); ds = obj.getProductData(); BindData(ds); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; CustomerBal obj = new CustomerBal(); DataSet ds = new DataSet(); ds = obj.getProductData(); BindData(ds); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string status = ((DropDownList)(GridView1.Rows[e.RowIndex].FindControl("ddlstatus"))).SelectedItem.Value; int orderid = int.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text); CustomerBal obj = new CustomerBal(); int i = obj.UpdateProduct(status, orderid); if (i > 0) { GridView1.EditIndex = -1; BindUpdatData(); Response.Write("Successfully Updated"); } else { Response.Write("Successfully Updated"); } } private void BindUpdatData() { CustomerBal obj = new CustomerBal(); DataSet ds = new DataSet(); ds = obj.getProductData(); BindData(ds); } }