我做的程序中,有好多数据浏览,同时也也有删除,
我删除时,点击就删除了,这样给用户不友好,
我使用的是在DataView中使用模板列,如何给用户提示?
请大家多多指教?

解决方案 »

  1.   

    javascript
    Response.Write("<script>if(confirm('Are you sure to delete?')){return;}</script>");
      

  2.   

    for (int i = 0; i < dg.Items.Count; i++)
            {
                ((LinkButton)dg.Items[i].Cells[列].Controls[1]).Attributes["OnClick"] = "javascript:return confirm('删除记录后不能还原,您确定删除吗?');";
            }
      

  3.   

    <asp:ButtonField ItemStyle-Width="60" ControlStyle-Width="53" ButtonType="Link" HeaderText="Delete" Text="Delete" CommandName="Delete"/>
    <asp:TemplateField ItemStyle-Width="60" ControlStyle-Width="53" HeaderText="Delete">
        <ItemTemplate>
           <asp:Button ID="Delete" runat="server" CommandName="Delete" Text="Delete"/>
        </ItemTemplate>
    </asp:TemplateField>
    protected void GridView1_RowDataBound ( object sender, GridViewRowEventArgs e )
        {
           if ( e.Row.RowType == DataControlRowType.DataRow )
            {
                ( ( LinkButton ) e.Row.Cells [ 5 ].Controls [ 0 ] ).Attributes.Add ( "onclick", "return confirm('Do you want to delete')" );
                ( ( Button ) e.Row.Cells [ 6 ].FindControl("Delete") ).Attributes.Add ( "onclick", "return confirm('Do you want to delete')" );
            }
        }
      

  4.   

    private void dg1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 

    //删除确认             
    LinkButton delBttn = (LinkButton) e.Item.Cells[6].Controls[0]; 
    delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除?');"); 
    }
    }