1
     <asp:GridView ID="GridView1" runat="server" 
                        AllowPaging="True" AllowSorting="True"
                        DataMember="DefaultView" 
                        DataSourceID="SqlDataSource1"...
     >
     <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:BoundField ...

                            <asp:CommandField  ButtonType="Image" DeleteText="Delete" ShowDeleteButton="True" DeleteImageUrl="images/deletered1.png"></asp:CommandField>                               
                        </Columns>                    
                        <FooterStyle BackColor="#507CD1" .../>
                    </asp:GridView>

I have a grid view with a an <asp:CommandField> in every row but I can't find a prperty to set a tooltip text("delete") or confirm message box (something like "Are you sure?" Yes No)

4

1 回答 1

2

尝试将您的转换CommandField为 a TemplateField,如下所示:

<asp:TemplateField HeaderText="Delete">
    <ItemTemplate>
        <asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Delete"
            OnClientClick="return confirm('Are you sure you want to delete this user?');" />
</ItemTemplate>
</asp:TemplateField>

然后你只需要处理你Command的代码隐藏。

于 2013-08-08T19:00:36.680 回答