2012-03-16 6 views
2

私はgridviewlinkbuttonをグリッドビューに持っています。 > rowCommand火災、 Rowviewの前にGridViewのLinkBut​​tonの確認ボックス

  • 無の場合>何も起こらない -

    LinkBut​​tonコントロールがクリックされる

    rowCommand火災は、しかし、私はイエス場合

    • 、comfirmationボックスとクリックをかご確認くださいをユーザーにお願いしたいと思います。

    方法が見つかりませんでした。

  • 答えて

    6

    は、LinkBut​​tonコントロールのOnClientClickプロパティとしてこれを追加します。

    OnClientClick="return confirm('Do you really want?');" 
    
    2

    はこれを試してみてください。

    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
        LinkButton del = e.Row.Cells[2].Controls[0] as LinkButton; 
        del.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this role?');"); 
    } 
    

    と私のマークアップ:後ろの私のコードで

    if (e.Row.RowType == DataControlRowType.DataRow){ 
    LinkButton link = (LinkButton)e.Row.FindControl("LinkButton1");  
    link .Attributes.Add("onclick", "return confirm('Are you sure to proceed with this 
    action?');"); 
    } 
    
    0

    <asp:GridView 
        ID="GridViewRoles" 
        runat="server" 
        Width="350px" 
        EmptyDataText="No Roles" 
        AutoGenerateColumns="False" 
        AllowPaging="False" 
        PageSize="50" 
        AllowSorting="True" 
        CssClass="gridview" 
        AlternatingRowStyle-CssClass="even" 
        OnRowCommand="GridViewRoles_RowCommand" 
        OnRowDataBound="GridViewRoles_RowDataBound" 
        OnRowDeleting="GridViewRoles_RowDeleting" OnRowEditing="GridViewRoles_RowEditing"> 
        <Columns> 
    
         <asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" HeaderStyle-Width="170px" HeaderStyle-HorizontalAlign="Left" /> 
         <asp:ButtonField CommandName="Edit" Text="Edit" HeaderStyle-Width="50px" /> 
         <asp:CommandField ShowDeleteButton="True" /> 
    
        </Columns> 
        <AlternatingRowStyle CssClass="even" /> 
    </asp:GridView> 
    
    関連する問題