Understanding Delete Link in ASP.NET Dynamic Data scaffolds

Since ASP.NET Dynamic Data Web Pages auto scaffolding does most of the things I need to do for this project, I would like to use it as a basis.

Now I would like to add another link to the "Change" "Delete" "Details" trio in my custom table view. I would like it to behave in the same way as the "Delete" button, i.e. Not calling another page, but doing something in the background (here: send an email.), And then refresh the view. Alas, I do not understand how this “Delete” link works.

It is defined in the automatically generated code as

<asp:LinkButton ID="DeleteLinkButton" 
     runat="server" CommandName="Delete"
     CausesValidation="false" Text="Delete"
     OnClientClick='return confirm("Are you sure you want to delete this item?");'/>

What exactly is going on here? Is there a method in the code somewhere called "Delete" (for example, used in the CommandName property)? What arguments are passed there? And: How can I name a custom method?

I tried to get through it with a debugger, but it's easy to lose myself in LINQ Dataclasses, so I haven't found anything.

Thanks in advance!

+1
source share
1 answer

Delete CommandName is usually associated with the equivalent DeleteCommand on the same page in the data tag, for example:

 <asp:SqlDataSource ID="SqlDataSourcePending" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionStringPending %>" 
        DeleteCommand="DELETE FROM [CSNTable] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [CSNTable] ([CSNDate], [CSNStatus], [CSNAuthor], [CSNSubject], [CSNMessage]) VALUES (@CSNDate, @CSNStatus, @CSNAuthor, @CSNSubject, @CSNMessage)" 
        SelectCommand="SELECT ID, CSNDate, CSNStatus, CSNAuthor, CSNSubject, CSNMessage FROM CSNTable WHERE (CSNStatus LIKE 'Pending')" 
        UpdateCommand="UPDATE [CSNTable] SET [CSNDate] = @CSNDate, [CSNStatus] = @CSNStatus, [CSNAuthor] = @CSNAuthor, [CSNSubject] = @CSNSubject, [CSNMessage] = @CSNMessage WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int16" />
        </DeleteParameters>
        <UpdateParameters>
            .........etc...

You can configure the delete command using the data source control property or through the page.

As for the new team, the usual way is to add a new link, change the team name to something that makes sense for what you want to do CommandName="EmailNotice".

, _ {YourDataTableName} _ItemCommand, eventargs.CommandName(e.CommandName), , , . e.CommandName == "EmailNotice", , .

EDIT: Linq ! MSDN, - GetCommand

+2

All Articles