How to create custom button in DetailsView in ASP.NET?

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

Actual scenario: I have a DetailsView connected in a sql server temporary table via ObjectDataSource. What I need to do is check / view each information in this table via DetailsView, and if I think the data is correct, I have to click on a specific button / hyperlink to transfer this data (row) to another table in this database.

Please help me...

+3
source share
1 answer

Select the tiny arrow at the top of the parts view and select Edit Fields.

Double-click ButtonField to add a button ...

Change the settings according to your needs (ButtonType and Text) and, most importantly, CommandName, which can be a "Check" for your script

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
        }

    }
+3
source

Source: https://habr.com/ru/post/1741098/


All Articles