protected void ButtonDelete_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd = new SqlCommand(String.Format("delete from tblProjSelect where UserID={0} AND ProjectName='{1}'", Session["_CurrentUserID"], DropDownListProjSelect.SelectedItem.Text), conn)) { try { cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } } } DropDownListProjSelect.Items.Clear(); DropDownListProjSelect.DataBind(); }
protected void ButtonModalCreate_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(g_sqlConn)) { Connect(conn); using (SqlCommand cmd = new SqlCommand("insert into tblProjSelect(UserID,ProjectName) values(@UserID, @ProjectName)", conn)) { try { cmd.Parameters.AddWithValue("@UserID", Session["_CurrentUserID"]); cmd.Parameters.AddWithValue("@ProjectName", TextBoxProjectName.Text); cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(String.Format("Error while executing query...{0}", ex.ToString())); } finally { Disconnect(conn); } } } DropDownListProjSelect.Items.Clear(); DropDownListProjSelect.DataBind(); }