简体   繁体   中英

Delete row from aspnet gridView via column button

I want to delete a row from an aspnet table, that have columnButton with [delete] button.

This is my code:

  <asp:GridView ID="GridInduccionPersona" runat="server" EnablePartialRendering="true" AutoGenerateColumns="False" DataKeyNames="RUT" CellPadding="4" ForeColor="#333333" GridLines="None" DeleteMethod="GridInduccionPersona_RowDeleting">
       <AlternatingRowStyle BackColor="White" />
       <Columns>
           <asp:BoundField DataField="RUT" HeaderText="Rut" InsertVisible="False"

. . .

           **<asp:ButtonField ButtonType="Button" CommandName="Delete" HeaderText="Eliminar" ShowHeader="True" Text="Eliminar" />**
       </Columns>

   </asp:GridView>

but when I put the page on Chrome; said: The Select operation is not supported unless you specify SelectMethod.

I just want to acces to function in server, and delete from gridview and database. I dont want to use linq or similar, Im working with stored procedure.

Any idea about that ? is SelectMethod important for delete from my column ? (I supposed that the button call the id, or some similar in gridview to delete)

From what I remember from ASP.net Webforms, the GridView needs the SelectMethod property configured to works properly.

SelectMethod should point to the method that obtains the records.

Without this property, GridView can't list the records, so you can't delete them.

So, set the SelectMethod property to target to the method that retrieves the records.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM