asp.net - Enable/disable button template of gridview -
how enable delete button if user have modify data in gridview
<edititemtemplate> <div class='actions'> <asp:button id="btnupdate" runat="server" text=" update " tooltip="update row" commandname="update" /> <asp:button id="btncancel" runat="server" text=" cancel " tooltip="cancel row" causesvalidation="false" commandname="cancel" /> </div> </edititemtemplate>
please use code. in source file
<asp:commandfield showeditbutton="true" showcancelbutton="true" headertext="edit / delete" itemstyle-width="8%" showdeletebutton="true" itemstyle-horizontalalign="left" headerstyle-horizontalalign="left" />
in cs file
protected void gvstatmeasures_rowediting(object sender, gridviewediteventargs e) { try { gvstatmeasures.editindex = e.neweditindex; // bind grid view } catch (exception ex) { fnmessage(true, ex.message); } } protected void gvstatmeasures_rowcancelingedit(object sender, gridviewcancelediteventargs e) { try { gvstatmeasures.editindex = -1; // bind grid view } catch (exception ex) { fnmessage(true, ex.message); } } protected void gvstatmeasures_rowdeleting(object sender, gridviewdeleteeventargs e) { try { int istatictypeid = int32.parse(gvstatmeasures.datakeys[e.rowindex].value.tostring()); // datakey value of gridview pk or else need identify records. // delete code //bind grid } catch (exception ex) { fnmessage(true, ex.message); } }
Comments
Post a Comment