简体   繁体   English

通过列按钮从aspnet gridView删除行

[英]Delete row from aspnet gridView via column button

I want to delete a row from an aspnet table, that have columnButton with [delete] button. 我想从aspnet表中删除具有columnButton和[delete]按钮的行。

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; 但是当我将页面放在Chrome上时; said: The Select operation is not supported unless you specify SelectMethod. 说: 除非指定SelectMethod,否则不支持Select操作。

I just want to acces to function in server, and delete from gridview and database. 我只想访问服务器中的功能,并从gridview和数据库中删除。 I dont want to use linq or similar, Im working with stored procedure. 我不想使用linq或类似的东西,我正在使用存储过程。

Any idea about that ? 有什么想法吗? is SelectMethod important for delete from my column ? SelectMethod对从列中删除是否重要? (I supposed that the button call the id, or some similar in gridview to delete) (我以为按钮会调用id,或在gridview中将其删除)

From what I remember from ASP.net Webforms, the GridView needs the SelectMethod property configured to works properly. 根据我从ASP.net Webforms所记得的内容,GridView需要将SelectMethod属性配置为可以正常工作。

SelectMethod should point to the method that obtains the records. SelectMethod应该指向获取记录的方法。

Without this property, GridView can't list the records, so you can't delete them. 没有此属性,GridView无法列出记录,因此您无法删除它们。

So, set the SelectMethod property to target to the method that retrieves the records. 因此,将SelectMethod属性设置为目标为检索记录的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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