用户单击ASP.Net DetailsView的“新建”按钮时触发的事件

时间:2021-11-10 15:43:03

In an ASP.Net VB.Net code-behind file, can you tell me what event fires that I can use to trap when the user clicks on the "New" button of a DetailsView at the time the DetailsView shows blank items such as DropDownLists, TextBoxes etc?

在ASP.Net VB.Net代码隐藏文件中,你可以告诉我当DetailsView显示空白项目(例如DropDownLists)时,当用户点击DetailsView的“新建”按钮时,我可以使用什么事件来捕获,TextBoxes等?

I need use this event handler to pre-select a value in a DropDownList obtained from a variable.

我需要使用此事件处理程序来预先选择从变量获取的DropDownList中的值。

1 个解决方案

#1


1  

Try the ItemCommand event. This is how to use it. I only know C# , but I think you get the hang of it.

尝试ItemCommand事件。这是如何使用它。我只知道C#,但我认为你掌握了它。

Code behind:

代码背后:

protected void DetailsView_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
    if (e.CommandName == "New")
    {
        // Your code here
    }
}

Markup:

标记:

<asp:DetailsView ID="DetailsView" runat="server" OnItemCommand="DetailsView_ItemCommand" ...

#1


1  

Try the ItemCommand event. This is how to use it. I only know C# , but I think you get the hang of it.

尝试ItemCommand事件。这是如何使用它。我只知道C#,但我认为你掌握了它。

Code behind:

代码背后:

protected void DetailsView_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
    if (e.CommandName == "New")
    {
        // Your code here
    }
}

Markup:

标记:

<asp:DetailsView ID="DetailsView" runat="server" OnItemCommand="DetailsView_ItemCommand" ...