how to disable a button on template column in datagridview?

Posted on 2008-10-14
Medium Priority
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
Question by:rajeev_23
  • 2
  • 2
LVL 16

Accepted Solution

Gyanendra Singh earned 2000 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;


Author Closing Comment

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.

Author Comment

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

LVL 16

Expert Comment

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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

627 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