开发者

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

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 hype开发者_StackOverflow中文版rlink 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...


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
        }

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜