public void DeleteItem(object sender, System.EventArgs e) { String AgreePercentProtestID = ((HtmlAnchor)sender).HRef.ToString(); int i = AreaClass.Delete(AgreePercentProtestID); if (i == 0) { LblMsg.Text = " error "; ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('خطا در حذف');", true); } else { BindGrid(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int id = e.RowIndex; if (e.ColumnIndex == 1) { btn_save.Tag = dataGridView1.Rows[id].Cells["Column4"].Value; txt_model.Text = dataGridView1.Rows[id].Cells["Column5"].Value.ToString(); cb_CarBrand.SelectedValue =dataGridView1.Rows[id].Cells["Column1"].Value; } else if (e.ColumnIndex == 2) { if (MessageBox.Show("هل انت متأكد انك تريد الحذف", "تحذير", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { brands.Delete(int.Parse(dataGridView1.Rows[id].Cells["Column4"].Value.ToString())); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = brands.SelectAll(); } } }