コード例 #1
0
        protected void cancelButton_Click(object sender, EventArgs e)
        {
            ModalExtender.Hide();
            ViewState["rowToDelete"] = null;
            string sql = (string)ViewState["isSearch"];

            this.bindTable(sql);
        }
コード例 #2
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            ViewState["rowToDelete"] = e.RowIndex;
            ModalExtender.Show();

            string sql = (string)ViewState["isSearch"];

            this.bindTable(sql);
        }
コード例 #3
0
        protected void deleteButton_Click(object sender, EventArgs e)
        {
            // Delete button in Confirm Delete Modal is clicked
            // Deletes the row specified in this.rowToDelete

            if (this.rowToDelete != -1)
            {
                int numPrimaryKeys = GridView1.DataKeyNames.Length;

                Dictionary <string, string> primaryKeys = new Dictionary <string, string>();

                for (int i = 0; i < numPrimaryKeys; i += 1)
                {
                    primaryKeys.Add(GridView1.DataKeyNames.GetValue(i).ToString(), GridView1.DataKeys[this.rowToDelete].Values[i].ToString());
                }

                string sql = db.getSqlDelete(primaryKeys, this.selectedTable);
                try
                {
                    SqlConnection conn = db.getConnection();
                    conn.Open();
                    SqlCommand command = db.getCommand(sql, conn);
                    command.ExecuteNonQuery();
                    this.bindTable();
                }
                catch (Exception err)
                {
                    statusPanel.Style.Add("display", "inline");
                    HtmlGenericControl h3 = new HtmlGenericControl("h3");
                    h3.InnerText = "DB Error";
                    statusPanel.Controls.Add(h3);
                    statusPanel.Controls.Add(new LiteralControl(err.Message));
                }
            }

            ModalExtender.Hide();
            ViewState["rowToDelete"] = null;
        }