c# - Gridview Data Update by textbox -
when trying update datagridview textbox value shows empty value in textbox code this.wt's wrong in this. bnddata() has dataset assign gridview
protected void gridview1_rowediting(object sender, gridviewediteventargs e) { gridview1.editindex = e.neweditindex; bnddata(); } protected void gridview1_rowupdating(object sender, gridviewupdateeventargs e) { gridviewrow row = (gridviewrow)gridview1.rows[e.rowindex]; string emailid = gridview1.rows[0].cells[0].text; textbox txtadress = (textbox)row.findcontrol("txtadress"); con.open(); string upd = "update empeasty set adress='" + txtadress.text+ "' emailid='"+emailid+"'"; sqlcommand cmd = new sqlcommand(upd,con); int i=cmd.executenonquery(); if (i > 0) response.write("data updated"); else response.write("data not updated"); con.close(); gridview1.editindex = -1; bnddata(); }
let's break down based on know question , comments.
you're trying update data (the address) in database, it's coming blank on postback after data bound.
i don't see exception handling in code, , haven't indicated errors, tells me code executing without run-time exceptions. since postback appears complete (based on know), tells me there's issue update sql command.
string upd = "update empeasty set adress='" + txtadress.text+ "' emailid='"+emailid+"'";
unless you've got exception handling @ application level, it's reasonable assume command executed. means either txtaddress.text empty, or there no rows in table in database had matching emailid.
the quickest way see sql string looks click in left-hand vertical grey bar set breakpoint (a red dot should show up) next line set sql.
then hit f5 (to start application in debug mode), enter value address in text box, hit submit (or whatever button have make update). when program reaches point set breakpoint, can step through code, , can examine values of txtaddress.text, emailid , upd see are.
if txtaddress.text or emailid blank, there's answer. if emailid not blank, have incorrect value , you'll need figure out why.
it may not seem it, have need determine root cause of problem you're seeing.
Comments
Post a Comment