Enabling all buttons in a repeater except for the clicked one
Posted
by
NewAmbition
on Stack Overflow
See other posts from Stack Overflow
or by NewAmbition
Published on 2012-11-22T10:58:15Z
Indexed on
2012/11/22
10:59 UTC
Read the original article
Hit count: 149
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?
© Stack Overflow or respective owner