asp.net - template field (button) of the grid executing on page refresh -
i have button template field in hierarchical grid , on button updating data when user hit browser refresh button executes ..whats solution..
here code behind
protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if (!page.ispostback) { if (e.commandname == "updatebilldata") { gridviewrow row = ((control)e.commandsource).namingcontainer gridviewrow; int index = row.rowindex; int billgenid = convert.toint32(gridview1.datakeys[index].value); dropdownlist ddmonths = (dropdownlist)row.findcontrol("ddbillingmonths"); textbox cunit = (textbox)row.findcontrol("txtcurrbillunits"); textbox amountbdue = (textbox)row.findcontrol("txtamountbduedate"); textbox advitax = (textbox)row.findcontrol("txtadvincometax"); textbox whtax = (textbox)row.findcontrol("txtwholdingtax"); textbox gst = (textbox)row.findcontrol("txtgst"); textbox amountafterdd = (textbox)row.findcontrol("txtamtafterdd"); textbox duedate = (textbox)row.findcontrol("txt_billduedate"); textbox billingdate = (textbox)row.findcontrol("txt_billgendate"); textbox remarks = (textbox)row.findcontrol("txtothers"); //update bill data procedure database db = databasefactory.createdatabase(); dbcommand cmd = db.getstoredproccommand("sp_update_genbill"); db.addinparameter(cmd, "@gridrowid", system.data.dbtype.int32); db.setparametervalue(cmd, "@gridrowid", billgenid); db.addinparameter(cmd, "@bmonth", system.data.dbtype.string, 3); db.setparametervalue(cmd, "@bmonth", ddmonths.selectedvalue); //execute stored procedure int = 0; = db.executenonquery(cmd); if (i != 0) { showalert("succesfuly updated..."); } else showalert("error occured while updating..."); } } }
my guess last postback before each refresh control command associated it. when hit refresh in browser, reposts command. try going browser's address field , hitting enter. same results?
Comments
Post a Comment