如何在gridview中使用autogeneratedelete,autogenerateEdit按钮 [英] how to use autogeneratedelete,autogenerateEdit button in gridview

查看:93
本文介绍了如何在gridview中使用autogeneratedelete,autogenerateEdit按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设置autogeneratedelete属性''true'之后,接下来的步骤是什么。如果需要执行任何代码,那么请帮我编写代码,因为我不知道之后的下一步是什么。

after seting autogeneratedelete property ''true'',what is next step after that.if any code is require to do ,then help me with code,because i don''t know what is next step after that.

推荐答案

它取决于你如何设置gridview的数据源。如果您正在使用数据源控件,例如SqlDataSource或EntityDataSource,并且您已将它们配置为处理数据删除,那么您应该很高兴。 gridview将自动尝试使用数据源定义的delete函数。如果您手动设置gridview的数据源,那么您可以使用gridview的RowCommand事件并在后面的代码中处理CommandName删除(更新以进行编辑)。



it depends on how you''re setting the datasource for the gridview. If you are using a datasource control, such as a SqlDataSource or EntityDataSource, and you have them configured to handle deletion of data then you should be good to go. The gridview will automatically try to use the delete function defined by the datasource. If you are manually setting the datasource for the gridview then you can use the gridview''s RowCommand event and handle the CommandName "Delete" ("Update" for edit) in the code behind.

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Delete")
    {
        // Handle Delete
    }
}





你的gridview应该是这样的:





Your gridview should look something like this:

<asp:gridview id="GridView1" 

              onrowcommand="GridView1_RowCommand"

              runat="server" // Rest of gridview


这篇关于如何在gridview中使用autogeneratedelete,autogenerateEdit按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆