如何在 ASP.NET 的 DetailsView 中创建自定义按钮?

发布于 2024-08-28 20:00:42 字数 266 浏览 2 评论 0原文

我是 ASP.NET 的新手。我只是想问是否可以在DetailsView 中创建按钮或超链接。我知道DetailsView中有编辑、删除等功能,但我想为我自己的功能创建另一个按钮或超链接。

实际场景: 我有一个通过 ObjectDataSource 连接到临时 SQL Server 表中的 DetailsView。我需要做的是通过DetailsView 检查/查看该表中的每个数据,如果我认为数据正确,我必须单击某个按钮/超链接将该数据(行)传输到该数据库中的另一个表。

请帮我...

I am a newbie in ASP.NET. I just want to ask if it is possible to create a button or hyperlink in a DetailsView. I know that there are Edit, Delete, etc. in a DetailsView, but I want to create another button or hyperlink for my own function.

Actual Scenario:
I have a DetailsView connected in a temporary sql server table via ObjectDataSource. What I need to do is to check/view each data in that table through the DetailsView and if I think the data is correct, I must click a certain button/hyperlink to transfer that data (row) to another table in that DB.

Please help me...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜无邪 2024-09-04 20:00:42

选择详细信息视图顶部的小箭头,然后选择“编辑字段”

双击“ButtonField”以添加按钮...

更改设置以满足您的需求(ButtonType 和 Text),最重要的是 CommandName,它可能是“Check”以适合您的场景

对于该事件,请使用 ItemCommand 事件

 void MyDetailView_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
    {

        // Use the CommandName property to determine which button
        // was clicked. 
        if (e.CommandName == "Check")
        {

           //Do Anything you like
        }

    }

Select the tiny arrow on top of the details view and select Edit Fields

Double click the ButtonField to add a button...

Change the settings to suit your needs (ButtonType and Text) and most importantly CommandName which might be "Check" for your scenario

And for the event use the ItemCommand event

 void MyDetailView_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
    {

        // Use the CommandName property to determine which button
        // was clicked. 
        if (e.CommandName == "Check")
        {

           //Do Anything you like
        }

    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文