protected void gvSubGroups_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { //Retrieve the row index stored in the //CommandArgument property. int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button // from the Rows collection. GridViewRow row = gvSubGroups.Rows[index]; SubIDHolder.Text = row.Cells[0].Text; SubOldName.InnerText = row.Cells[1].Text; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#modalShowSubGroupDetails').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "ModalScript", sb.ToString(), false); } if (e.CommandName == "Delet") { //Retrieve the row index stored in the //CommandArgument property. int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button // from the Rows collection. GridViewRow row = gvSubGroups.Rows[index]; JobRepository repgp = new JobRepository(); if (repgp.DelJob(row.Cells[0].Text.ToInt())) { gvSubGroups.DataSource = null; gvSubGroups.DataBind(); if (ddlGroups.SelectedValue != "0") { gvSubGroups.DataSource = repgp.getJobsByGroupID(ddlGroups.SelectedValue.ToInt()); } else { gvSubGroups.DataSource = repgp.getAllJobsByGroupID(); } gvSubGroups.DataBind(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با موفقیت انجام شد');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با خطا مواجه شد ، بعدا سعی کنید یا با پشتیبانی تماس بگیرید!');", true); } } }