본문 바로가기
programming/ASP.NET

buttonfiled 에서 confirm 사용

by hotdogya 2010. 11. 5.

asp.net

 

문제의 buttonfield;;;

<asp:ButtonField CommandName="Button" Text="[삭제]">
<itemStyle Width="40px" />
</asp:ButtonField>

gridview에서 buttonfield는 OnClientClick속성이 없다.

난 자바스크립트 confirm을 써야하는데...

 

하지만 이미 onrowcommand로 이벤트가 걸려있기 때문에 다시 수정할라니 겁나서 ...

솔직히 내 소스 내가 잘 몰라서 ㅋㅋㅋ

 

암튼  닥치고 소스

바인딩할때 해당필드에 속성추가

 

    protected void CommentGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {          

             e.Row.Cells[3].Attributes.Add("onclick", "javascript:return " +"confirm('정말로 지울까요?')");
        }
    }