Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8611373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:21:35+00:00 2026-06-12T04:21:35+00:00

I have a delete button in my gridview, but I want this button not

  • 0

I have a delete button in my gridview, but I want this button not to work depending on the result of an sql query.

An example

I have a gridview with “ship containers”, and I want to remove one of the container from this list, but I want to display a message “to be able to delete this container, please remove it from the products”, so that if a ship container is in use, I need to prevent it from being deleted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:21:36+00:00Added an answer on June 12, 2026 at 4:21 am

    Here is the way you can do this:

    <asp:GridView ID="EntityGridView" runat="server" DataKeyNames="DocumentId" AutoGenerateColumns="False"
        AllowPaging="True" AllowSorting="False" SkinID="GridViewSmall" OnRowCommand="EntityGridView_RowCommand"
        OnPageIndexChanged="EntityGridView_PageIndexChanged">
        <Columns>
            <asp:TemplateField ItemStyle-CssClass="TemplateFieldThreeColumns">
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" ImageAlign="Top" runat="server" ImageUrl='<% #ResolveImageUrl(Eval("Extension").ToString()) %>'
                        ToolTip='<%# Eval("Extension").ToString() %>' CommandName="Select" CommandArgument='<%# Eval("DocumentId") %>' />
                <asp:ImageButton ID="btnDelete" runat="server" ToolTip="<% $resources:AppResource,Delete %>"
                    SkinID="DeletePage" OnClientClick="<%# GetDeleteConfirmation(Resources.AppResource.ConfirmDocumentDelete) %>"
                    CommandName="CustomDelete" CommandArgument='<%# Eval("DocumentId") %>' Visible='<% #AllowDocDelete(Container.DataItem) %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Title" HeaderText="<% $resources:AppResource,Title %>" />
            <asp:BoundField DataField="Author" HeaderText="<% $resources:AppResource,Author %>" />
            <asp:BoundField DataField="FileName" HeaderText="<% $resources:AppResource,FileName %>" />
            <asp:BoundField DataField="Created" HeaderText="<% $resources:AppResource,Created %>" />
        </Columns>
        <EmptyDataTemplate>
            <asp:Label ID="EmptyLabel" runat="server" Text='<%# Resources.AppResource.NoContentToDisplay %>' CssClass="NoDataLabel"></asp:Label>
        </EmptyDataTemplate>
    </asp:GridView>
    

    Take notice on AllowDocDelete function that disables delete button. This function should be declared inslide your page class, something like this:

        public bool AllowDocDelete(object item)
        {
            bool result = false; 
            //TODO: check your condition
            return result;
        }
    

    Item object represents binded entity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a delete button in a gridview. For those not familiar with asp.net
I have a delete button on my web site which I want to add
I have a in-line delete button, I want to append more data to the
i have a custom cell i want to delete it when a button is
I have a button inside my <ItemTemplate> in GridView and I want to call
I have a Gridview., usually, when the delete command button is clicked then the
I have the following image button on the GridView and I want to call
I've done this with a asp.net Gridview. but does anybody have any examples on
I have a gridview, on clicking a delete button, i need to remove the
I have a delete button on a gridview for each row that calls gvSiteInfo_RowDeleting(object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.