• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

how to disable a button on template column in datagridview?

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
rajeev_23
Asked:
rajeev_23
  • 2
  • 2
1 Solution
 
Gyanendra SinghArchitectCommented:
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
 
rajeev_23Author Commented:
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
 
rajeev_23Author Commented:
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
 
Gyanendra SinghArchitectCommented:
:) hehe thanks a lot ...
0
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

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now