Solved

how to disable a button on template column in datagridview?

Posted on 2008-10-14
4
717 Views
Last Modified: 2013-12-17
I have 2 Buttons on a template column of datagridview in webpage of asp.net.
My need is to disable a button on the page load event.

please help
0
Comment
Question by:rajeev_23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 500 total points
ID: 22709706
try this


foreach (GridViewRow row in Gridview1.Rows)
{
//access the button
Button cb = (Button )row.FindControl("YouFirstrbuttonId");
cb.Disable = true;
Button cb1 = (Button )row.FindControl("YourSecondbuttonId");
cb1.Disable = true;

}
0
 

Author Closing Comment

by:rajeev_23
ID: 31505807
it worked really Thanks Expert , I just changed a little, just the in place of button.disable  it was to be button.enabled=false.
0
 

Author Comment

by:rajeev_23
ID: 22709776
Thanks you all the Experts
This Solution really worked for me with a little change

foreach (GridViewRow row in GridView1.Rows)
        {
            //access the button
            Button cb = (Button)row.FindControl("Button2");
            cb.Enabled = false;
           
            //Button cb1 = (Button)row.FindControl("YourSecondbuttonId");
            //cb1.Disable = true;
 
        }

Open in new window

0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22709826
:) hehe thanks a lot ...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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