Hello,
I'm using a Gridview to display a list of servers. Each server has a column in a table called "Enabled." I want to create a button that is supposed to toggle the value called "Enabled." I am able to make the button either to set Enabled to true or false, but I don't know how to make it toggle.
Here is the command:
UpdateCommand="UPDATE [ServerStatus] SET [Enabled] = 1 WHERE [ServerName] = @.ServerName"
The button is a buttonfield in the gridview:
<asp:ButtonField ButtonType="Button" CommandName="Update" HeaderText="Toggle" ShowHeader="True" Text="Toggle" />
Does anyone know the syntax, or a way to make the button set Enabled to true when it is false, and false when it is set to true?
UPDATE [ServerStatus]SET [Enabled] =CASE [Enabled]WHEN 1THEN 0ELSE 1END WHERE [ServerName] = @.ServerNameThat should work for you if you want SQL Server to do the toggling.|||
Works like a charm.
Thanks dude.
No comments:
Post a Comment