Share via


List.ItemCommand 이벤트

정의

사용자가 List 컨트롤과 연결된 명령을 선택할 때 이 이벤트가 발생합니다. 이 API는 더 이상 사용되지 않습니다. ASP.NET 모바일 애플리케이션을 개발하는 방법에 대한 자세한 내용은 ASP.NET 있는 Mobile Apps & 사이트를 참조하세요.

public:
 event System::Web::UI::MobileControls::ListCommandEventHandler ^ ItemCommand;
public event System.Web.UI.MobileControls.ListCommandEventHandler ItemCommand;
member this.ItemCommand : System.Web.UI.MobileControls.ListCommandEventHandler 
Public Custom Event ItemCommand As ListCommandEventHandler 

이벤트 유형

예제

다음 코드 예제에서는 사용 하는 ItemCommand 방법을 보여 줍니다는 이벤트 목록에서 항목의 상태 변경 하 고 상태 합계를 다시 계산 하는 메서드를 호출 합니다. 이 예제는에 대 한 보다 큰 예제의 일부는 List 개요.

private void Status_ItemCommand(object sender, 
    ListCommandEventArgs e)
{
    const string spec = "You now have {0} " + 
        "tasks done, {1} tasks scheduled, and " +
        "{2} tasks pending.";

    // Move selection to next status toward 'done'
    switch (e.ListItem.Value)
    {
        case "scheduled":
            schedCount -= 1;
            pendCount += 1;
            e.ListItem.Value = "pending";
            break;
        case "pending":
            pendCount -= 1;
            doneCount += 1;
            e.ListItem.Value = "done";
            break;
    }

    // Show the status of the current task
    Label1.Text = e.ListItem.Text + " is " +
        e.ListItem.Value;

    // Show current selection counts
    Label2.Text = String.Format(spec, doneCount, 
        schedCount, pendCount);
}
Private Sub Status_ItemCommand(ByVal sender As Object, _
    ByVal e As ListCommandEventArgs)

    Const spec As String = "You now have {0} tasks done, {1} " & _
        "tasks scheduled, and {2} tasks pending."

    ' Move selection to next status toward 'done'
    Select Case e.ListItem.Value
        Case "scheduled"
            schedCount -= 1
            pendCount += 1
            e.ListItem.Value = "pending"
        Case "pending"
            pendCount -= 1
            doneCount += 1
            e.ListItem.Value = "done"
            
    End Select

    ' Show the status of the current task
    Label1.Text = e.ListItem.Text & " is " & _
        e.ListItem.Value

    ' Show current selection counts
    Label2.Text = String.Format(spec, doneCount, _
        schedCount, pendCount)
End Sub

설명

템플릿 ItemCommand 을 사용하여 목록을 렌더링하는 경우 이벤트 처리기는 ASP.NET 이벤트 버블링 메커니즘을 통해 호출됩니다. 이벤트 처리기는 원본 항목 및 CommandName 이벤트를 생성한 컨트롤의 속성에 대한 정보를 포함하는 형식ListCommandEventArgs의 인수를 전달합니다. 이 옵션을 사용 하면 여러 관련된 상호 작용을 사용 하 여 단일 목록 항목을 렌더링할 수 있습니다.

기본 렌더링에서 컨트롤은 사용자가 목록 항목을 클릭할 수 있는 기본 UI(사용자 인터페이스)를 제공합니다. 포스트백 시 ItemCommand 이벤트 처리기는 소스 항목에 대한 정보를 포함하는 형식 ListCommandEventArgs의 인수를 사용하여 호출됩니다. 이 개체의 속성은 CommandName 입니다 null.

적용 대상

추가 정보