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.
Alex,
Thanks for posting the sample code to change the button in a row.
I tried it out and it worked as expected.
Thanks!
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; }
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.