Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
895
How can I disable / hide a button for some rows and not others?
posted

I've placed a button in the template of a column. I'm able to click on the button and perform my action. However, I don't want the button to show up in every row for that column.

I'm able to get the GridRecordItem for the desired cell in the InitializeRow event for the grid.

I was trying to disable / hide the button during the InitializeRow event of the grid.

But, I have not figured out how to disable / hide the button yet.

Can someone tell me how I can accomplish this?

Thanks,

Brian.

Parents
  • 15979
    Verified Answer
    posted

    Hello Brian,

    I am suggesting that you are using ASP Button (in the bellow sample code with ID “btn1”) and you want to hide some of the buttons in certain rows. The code bellow will hide the button in forth row (in “InitializeRow” event):

    if (e.Row.Index == 3)

    {

     

       Button btn = (Button)e.Row.Items[4].FindControl("btn1");

        btn.Visible = false;

    }

     

    Test this approach in your sample and let me know what the results are.

Reply Children
No Data