protected void LoadState() { BusinessLayer.State ObjState = new BusinessLayer.State(); DataTable dt = ObjState.GetAll(); ViewState["State"] = dt; }
protected void dgvState_RowDeleting(object sender, GridViewDeleteEventArgs e) { StateId = Convert.ToInt32(dgvState.DataKeys[e.RowIndex].Value.ToString()); BusinessLayer.State ObjState = new BusinessLayer.State(); ObjState.Delete(StateId); LoadStateList(); }
protected void dgvState_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("AddUpdate")) { int RowIndex = Convert.ToInt32(e.CommandArgument.ToString()); StateId = Convert.ToInt32(dgvState.DataKeys[RowIndex].Value.ToString()); BusinessLayer.State ObjState = new BusinessLayer.State(); Entity.State State = new Entity.State(); State.StateId = StateId; State.StateName = ((TextBox)dgvState.Rows[RowIndex].FindControl("txtState")).Text; ObjState.Save(State); LoadStateList(); } }
protected void LoadStateList() { BusinessLayer.State ObjState = new BusinessLayer.State(); DataTable dt = ObjState.GetAll(); DataRow dr = dt.NewRow(); dr["StateId"] = "0"; dr["StateName"] = ""; dt.Rows.InsertAt(dr, 0); dt.AcceptChanges(); dgvState.DataSource = dt; dgvState.DataBind(); }