protected void gvGroups_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 = gvGroups.Rows[index]; IDholder.Text = row.Cells[0].Text; tbxOldName.InnerText = row.Cells[1].Text; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#modalShowGroupDetails').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterStartupScript(this, this.GetType(), "ModalScript", sb.ToString(), false); } if (e.CommandName == "Delet") { JobGroupsRepository repJgp = new JobGroupsRepository(); JobRepository repgp = new JobRepository(); // 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 = gvGroups.Rows[index]; int id = row.Cells[0].Text.ToInt(); if (repgp.DelJobs(id)) { if (repJgp.DelJobGruop(id)) { gvGroups.DataSource = null; gvGroups.DataBind(); ddlGroups.DataSource = null; ddlGroups.DataBind(); gvSubGroups.DataSource = null; gvSubGroups.DataBind(); DataTable allGroups = new DataTable(); allGroups = repJgp.getJobGroups(); ddlgroupsForModal.DataSource = allGroups; ddlgroupsForModal.DataTextField = "JobGroupTitle"; ddlgroupsForModal.DataValueField = "JobGroupID"; ddlgroupsForModal.DataBind(); ddlgroupsForModal.Items.Insert(0, new ListItem("یکی از گروه ها را انتخاب کنید", "0")); gvGroups.DataSource = allGroups; gvGroups.DataBind(); ddlGroups.DataSource = allGroups; ddlGroups.DataTextField = "JobGroupTitle"; ddlGroups.DataValueField = "JobGroupID"; ddlGroups.DataBind(); ddlGroups.Items.Insert(0, new ListItem("همه زیر گروه ها", "0")); gvSubGroups.DataSource = repgp.getAllJobsByGroupID(); gvSubGroups.DataBind(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با موفقیت انجام شد');", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با خطا مواجه شد ، بعدا سعی کنید یا با پشتیبانی تماس بگیرید!');", true); } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('حذف با خطا مواجه شد ، بعدا سعی کنید یا با پشتیبانی تماس بگیرید!');", true); } } }