Disabling Edit buttons in gridview

Posted on 2009-02-19
Last Modified: 2012-08-14
hello all,

I'm using the code below to disable the "delete" and "status" buttons while in edit mode. The problem I'm facing is that it only disables the "delete" and "status" button of the row which is in edit mode. The "delete" and "status" buttons for the rest of the rows are still visible. I want to disable them as well.

Any tips or idea would be appreciated
            gvUserLevel.EditIndex = e.NewEditIndex;


            Button btn = (Button)gvUserLevel.Rows[e.NewEditIndex].FindControl("btnDelete");

            btn.Enabled = false;

            Button btn1 = (Button)gvUserLevel.Rows[e.NewEditIndex].FindControl("btnStatus");

            btn1.Enabled = false;

            TextBox txtUserLevel = (TextBox)gvUserLevel.Rows[e.NewEditIndex].FindControl("EditUserlevelName");

            txtUserLevel.Text = txtUserLevel.Text.Trim();

Open in new window

Question by:AvinashKN
    1 Comment
    LVL 11

    Accepted Solution

    foreach (GridViewRow row in gvUserLevel.Rows)
                ((Button)row.FindControl("btnDelete")).Enabled = false;
                ((Button)row.FindControl("btnStatus")).Enabled = false;

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now