javascript
  • asp.net
  • gridview
  • 2011-04-12 41 views 1 likes 
    1

    我想要的是在我的datagridview中刪除記錄之前有一個確認。請檢查我的代碼..謝謝。如何把一個確認在超鏈接DataGridView

    這裏是我的asp.net代碼:

    <ItemTemplate><asp:HyperLink ID="hlnk_Delete" runat="server" style="width:100px; margin-left:50px; margin-right:100px" 
        NavigateUrl='<%# "Components/DeleteBook.aspx?SKU=" + Utility.SKUMask(Eval("lbhc_lb_sku").ToString()) %>'>Delete</asp:HyperLink></ItemTemplate> 
    

    的SqlDataSource:

    <asp:SqlDataSource ID="sds_PublishedBookListings" runat="server" ConnectionString="<%$ ConnectionStrings:learningisfunConnectionString %>" 
    
    SelectCommand="SELECT dbo.lif_bookshascategory.lbhc_lc_id,dbo.lif_books.lb_sku, dbo.lif_bookshascategory.lbhc_lb_sku, dbo.lif_category.lc_category, dbo.lif_books.lb_title, &#13;&#10;      dbo.lif_bookshascategory.lbhc_level&#13;&#10;FROM   dbo.lif_bookshascategory INNER JOIN&#13;&#10;      dbo.lif_category ON dbo.lif_bookshascategory.lbhc_lc_id = dbo.lif_category.lc_id INNER JOIN&#13;&#10;      dbo.lif_books ON dbo.lif_bookshascategory.lbhc_lb_sku = dbo.lif_books.lb_sku&#13;&#10;WHERE  (dbo.lif_books.lb_status = 'publish') and lbhc_level = 1&#13;&#10;" 
    
    DeleteCommand="DELETE FROM lif_books FROM lif_books INNER JOIN lif_bookshascategory ON lif_books.lb_sku = lif_bookshascategory.lbhc_lb_sku WHERE (lif_books.lb_sku = @lbhc_lb_sku) OR (lif_bookshascategory.lbhc_lb_sku = @lbhc_lb_sku)"> 
    <DeleteParameters> 
    <asp:Parameter Name="lb_sku" Type="String" /> 
    </DeleteParameters> 
    </asp:SqlDataSource> 
    

    回答

    4

    添加該超鏈接

    onclick="javascript:return confirm('Are you sure you want to delete ?');" 
    
    <ItemTemplate><asp:HyperLink ID="hlnk_Delete" onclick="javascript:return confirm('Are you sure you want to delete ?');" runat="server" style="width:100px; margin-left:50px; margin-right:100px" 
    NavigateUrl='<%# "Components/DeleteBook.aspx?SKU=" + Utility.SKUMask(Eval("lbhc_lb_sku").ToString()) %>'>Delete</asp:HyperLink></ItemTemplate> 
    
    +0

    確定。其工作表示感謝! – 2011-04-12 06:30:58

    1
    0

    添加到你超鏈接的OnClientClick = 「確認( '你確定嗎?');返回false」

    +0

    上有onClientClick屬性存在超鏈接。 – 2011-04-12 06:27:04

    相關問題