Create a conditional button
You can make the appearance of a button conditional. First we add the code to add a button called ‘Do Something’. The button in our example will execute a stored procedure [dbo].[DoSomething] when it’s pressed.
<Group>
<Controls>
<Control ID='Button Do Something'>
<Type>Button</Type>
<Caption>Do something</Caption>
<Click>
<DataID>Data OurDataset</DataID>
<Active>
<NonQuery>
<![CDATA[
EXEC [dbo].[DoSomething]
]]>
</NonQuery>
</Active>
</Click>
</Control>
</Controls>
</Group>
There will probably be more ‘Controls’ in the Group but for this example we just isolated our button. Next we add the code to make the button conditional. This code should be at the end of the command, so under the definition of the button.
<Process ID='Process'>
<DataID>Data OurDataset</DataID>
<Active>
<AdjustControls>
<Select>
<![CDATA[
SELECT 'Button Do Something' AS [Control ID]
, CASE WHEN <your condition here>
THEN 1
ELSE 0
END AS [Visible]
<AdjustControls>
</Active>
</Process>
The dataID on must be the same on both the definition of the button and the code to make the button optional. The data used to make your condition must also be in this dataID.
