导航

GridView中删除行的提示

Posted on 2006-11-13 11:56  急惊风  阅读(495)  评论(0)    收藏  举报
GridView中删除行的提示
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    
{
        
foreach (TableCell tc in e.Row.Cells)
        
{
            
if (tc.Controls.Count > 0)
            
{
                
foreach (Control con in tc.Controls)
                
{
                    
if (con.GetType().ToString() == "System.Web.UI.WebControls.DataControlLinkButton")
                    
{
                        LinkButton lb 
= (LinkButton)con;
                        
if (lb.CommandName == "Delete")
                        
{
                            lb.Attributes.Add(
"onclick""return confirm('您真的要删除这条记录吗?')");
                        }

                    }

                }

            }

        }

    }


请问有没有更好的方法?