문제

GridView가 있고 그 gridview에서 다음과 같이 Addhandler를 사용하여 프로그래밍 방식으로 ImageButtons 목록을 만들었습니다.

Dim deletecshr As New ImageButton
deletecshr.ImageUrl = "\images\bttnDeletemini.gif"
deletecshr.ToolTip = "This Will Delete All Cashiers"
AddHandler deletecshr.Click, AddressOf deletecshr_Click
deletecshr.Attributes.Add("onclick", "javascript: if(confirm('Are you sure you want to delete all of these cashiers?')==false) return false;")

    If e.Row.Cells.Count > 2 And e.Row.RowType <> DataControlRowType.Header And e.Row.RowType <> DataControlRowType.Footer Then
        e.Row.Cells(3).Controls.Add(deletecshr)
    End If

내 문제는 클릭 핸들러에서 클릭 된 ImageButton의 행 값을 얻는 것입니다. 어떻게 얻습니까?

도움이 되었습니까?

해결책

할당하는 것이 좋습니다

imageButton.CommandName = "Delete"
imageButton.CommandArgument = Your_Row_ID_You_Want_To_Get

그런 다음 ImageButton.oncommand를 사용하여 작업을 수행합니다.

편집하다:다음은 다음 단계입니다.

  1. RowCreated에서 이미지 버튼을 만듭니다
  2. rowdatabound에서 이미지 버튼의 명령 이름 및 지휘부 지정
  3. RowCommand에서 해당 행의 이미지 버튼을 확인하면 이전에 저장 한 ID가 표시됩니다.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top