asp.net - how to change data in the column as "N" automatically instead of deleting, after selecting the checkbox &click on delete button -


when inserting record table, in "state" column inserting "a".
want automatically change "a" "n" after have checked checkbox , clicked on delete button.

can please me?

string constr = configurationmanager.connectionstrings["webconnectionstring"].connectionstring;  protected void btndelete_click(object sender, eventargs e) {    foreach (gridviewrow row in gridview1.rows) {          checkbox chk = (checkbox)row.findcontrol("chkselect");         if (chk.checked == true)         {             int cnt= int.parse(gridview1.datakeys[row.rowindex].value.tostring());             sqlconnection con = new sqlconnection(constr);             string sql = "delete pa_webwork sno = @sno ";             sqlcommand cmd = new sqlcommand(sql, con);             cmd.parameters.addwithvalue("@sno", cnt);             con.open();             cmd.executenonquery();             con.close();         }     }    gridview1.databind(); } 

   database     :: web    table name   :: pa_webwork     column names ::              sno         :: int             article no  :: varchar(50)             state       :: varchar(50)             date        :: smalldatetime 

u can write update statement

            int cnt= int.parse(gridview1.datakeys[row.rowindex].value.tostring());             sqlconnection con = new sqlconnection(constr);             string sql = "update  pa_webwork set state 'n'  sno = @sno ";             sqlcommand cmd = new sqlcommand(sql, con);             cmd.parameters.addwithvalue("@sno", cnt);             con.open();             cmd.executenonquery();             con.close(); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -