Enabling all buttons in a repeater except for the clicked one
- by NewAmbition
I have a Repeater Control with various buttons in it.
When the button gets clicked, it needs to disable itself so it cant be clicked again. Working.
However, when I click that button, it needs to enable any other button but it.
So, When I click on it, it needs to disable. When I click on another one, the previous button must enable, and that one must disable.
So for I've tried:
Button btnLoad = (Button)e.Item.FindControl("btnLoad");
foreach (Button b in e.Item.Controls.OfType<Button>().Select(c => c).Where(b => b != btnLoad))
{
b.Enabled = true;
}
btnLoad.Text = "Currently Viewing";
btnLoad.Enabled = false;
But it isnt working. Depending on where I put it, its either leaving all the buttons enabled (But still changing its text), or not doing anything at all.
What do I need to do to make this work?