Question

     <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)

Was it helpful?

Solution

Try converting your CommandField to a TemplateField, like this:

<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>

Then you just need to handle your Command in code-behind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top