Tuesday 15 March 2011

c# - asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true" the OnRowDeleting not working -



c# - asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true" the OnRowDeleting not working -

excuse me, next this tutorial on tutorial, command field using link.. want utilize button instead of linkbutton.. alter code this:

<asp:commandfield buttontype="button" showeditbutton="true" showdeletebutton="true" headertext="action" itemstyle-width="150" />

behind code this:

protected void onrowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow && e.row.rowindex != gridviewpaging.editindex) { (e.row.cells[3].controls[2] button).attributes["onclick"] = "return confirm('do want delete row?');"; } }

then onrowdeleting method not working...

protected void onrowdeleting(object sender, gridviewdeleteeventargs e) { int sales_so_id = convert.toint32(gridviewpaging.datakeys[e.rowindex].values[0]); //delete operation sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].tostring()); con.open(); sqlcommand cmd = new sqlcommand("deleteso", con); cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add(new sqlparameter("@sales_so_id", sqldbtype.int)); cmd.parameters["@sales_so_id"].value = sales_so_id; cmd.executenonquery(); con.close(); getdata(); }

what should do? when utilize linkbutton, ok.. but, onrowdeleting behind code not working.. please help.

finally, utilize this tutorial

my previous ondatabound this:

if (e.row.rowtype == datacontrolrowtype.datarow && e.row.rowindex != gridviewpaging.editindex) { (e.row.cells[3].controls[2] button).attributes["onclick"] = "return confirm('do want delete row?');"; }

and alter this:

if (e.row.rowtype == datacontrolrowtype.datarow) { string item = e.row.cells[0].text; foreach (button button in e.row.cells[3].controls.oftype<button>()) { if (button.commandname == "delete") { button.attributes["onclick"] = "if(!confirm('do want delete " + item + "?')){ homecoming false; };"; } } }

now working.. give thanks you

c# asp.net

No comments:

Post a Comment