출처: http://brian.chipsofttech.com/post/DetailsView-Confirm-Delete.aspx

itemCreated 이벤트에서 사용하면 된다.

protected void DetailsView1_ItemCreated(object sender, EventArgs e)
        {
            // Test FooterRow to make sure all rows have been created
            if (DetailsView1.FooterRow != null)
            {
                // The command bar is the last element in the Rows collection
                int commandRowIndex = DetailsView1.Rows.Count - 1;
                if (commandRowIndex > 0)
                {
                    DetailsViewRow commandRow = DetailsView1.Rows[commandRowIndex];
                    // Look for the DELETE button
                    DataControlFieldCell cell = (DataControlFieldCell)commandRow.Controls[0];
                    foreach (Control ctl in cell.Controls)
                    {
                        LinkButton link = ctl as LinkButton;
                        if (link != null)
                        {
                            if (link.CommandName == "Delete")
                            {
                                link.ToolTip = "Click here to delete";
                                link.OnClientClick = "return confirm('Do you really want to delete this record?');";
                            }
                        }
                    }
                }
            }
        }

Posted by 노을지기

댓글을 달아 주세요