private void BindGrid() { List <CPT_AccountMaster> lstAccount = new List <CPT_AccountMaster>(); AccountMasterBL clsAccount = new AccountMasterBL(); lstAccount = clsAccount.getAccount(); gvAccount.DataSource = lstAccount; gvAccount.DataBind(); }
protected void delete(object sender, GridViewDeleteEventArgs e) { CPT_AccountMaster accountdetails = new CPT_AccountMaster(); int id = int.Parse(gvAccount.DataKeys[e.RowIndex].Value.ToString()); accountdetails.AccountMasterID = id; AccountMasterBL deleteAccount = new AccountMasterBL(); deleteAccount.Delete(accountdetails); BindGrid(); }
protected void update(object sender, GridViewUpdateEventArgs e) { try { CPT_AccountMaster accountdetails = new CPT_AccountMaster(); int id = int.Parse(gvAccount.DataKeys[e.RowIndex].Value.ToString()); accountdetails.AccountMasterID = id; string accountName = ((TextBox)gvAccount.Rows[e.RowIndex].Cells[2].Controls[0]).Text; accountdetails.AccountName = accountName; AccountMasterBL updateAccount = new AccountMasterBL(); updateAccount.Update(accountdetails); gvAccount.EditIndex = -1; BindGrid(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
protected void AccountAddButton_Click(object sender, EventArgs e) { try { //if (AccountNameTextBox.Text.Trim().Length == 0) //{ // System.Windows.Forms.MessageBox.Show(new System.Windows.Forms.Form { TopMost = true }, "Don't accept Space char in your name"); // Focus(); //} CPT_AccountMaster accountdetails = new CPT_AccountMaster(); accountdetails.CityID = Convert.ToInt32(CityList.SelectedValue); accountdetails.AccountName = AccountNameTextBox.Text.Trim(); accountdetails.IsActive = true; AccountMasterBL insertAccount = new AccountMasterBL(); insertAccount.Insert(accountdetails); BindGrid(); CleartextBoxes(this); } catch (Exception ex) { Console.WriteLine(ex.Message); } }