asp.net - CommandField: Can I prohibit Update and Cancel when Edit clicked -


i using vs2010, .net 4. first column in gridview commandfield on initial rendering shows edit delete , set default linkbuttons. when edit clicked have popup form when accepted updates database. problem commandfield shows update , cancel dont want.

is there way prevent update , cancel when edit clicked.

thanks in advance help.

this partial gridview:

<asp:gridview runat="server" id="lstcomponents" width="100%" borderwidth="1px" borderstyle="none" enableviewstate="true" autogeneratecolumns="false"  datakeynames="componentid,componentname,componenttype,ipaddress"  cellpadding="0" cellspacing="0" onrowdatabound="lstcomponents_rowdatabound" allowsorting="false" headerstyle-cssclass="listheader" headerstyle-forecolor="white" onselectedindexchanging="lstcomponents_selectedindexchanging" onrowediting="lstcomponents_rowediting" onrowdeleting="lstcomponents_rowdeleting" > <columns>  <asp:commandfield  showdeletebutton="true" showselectbutton="true" showeditbutton="true"  headerstyle-cssclass="listheader" selecttext="set default" itemstyle-cssclass="listdata" headerstyle-width="150px"> <headerstyle cssclass="listheader" width="150px" /> <itemstyle cssclass="listdata" /> </asp:commandfield> 

remove showeditbutton="true" asp:commandfield , add linkbutton additionally within itemtemplate , perform logic in linkbutton's onclick event/onclientclick event .

see updated code,

           <asp:gridview runat="server autogeneratecolumns="false"   datakeynames="componentid,componentname,componenttype,ipaddress"                              cellpadding="0" cellspacing="0" onrowdatabound="lstcomponents_rowdatabound"                              headerstyle-cssclass="listheader" headerstyle-forecolor="white" onselectedindexchanging="lstcomponents_selectedindexchanging"                             onrowediting="lstcomponents_rowediting" onrowdeleting="lstcomponents_rowdeleting" >                             <columns>          <asp:templatefield>                <itemtemplate>                                                           <asp:linkbutton id="linkbutton1" onclick="linkbutton1_click" runat="server" text="edit">linkbutton</asp:linkbutton>                 </itemtemplate>         </asp:templatefield>          <asp:commandfield  showdeletebutton="true" showselectbutton="true"                                     headerstyle-cssclass="listheader" selecttext="set default" itemstyle-cssclass="listdata"                                     headerstyle-width="150px">                                     <headerstyle cssclass="listheader" width="150px" />                                     <itemstyle cssclass="listdata" />                                 </asp:commandfield> 

hope helps you...


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -