0

I have a Gridview (connected to a Datasource), in the first column is a flag which is either a 1 or a 0. I want to add a column with a button.

If the flag in column one = 1 then the button should say 'Hide', if the flag is 0 it should say 'Show'.

I need it to do this for all rows in the gridview

Can someone give me some pointers? Thanks

2 Answers 2

1

In button control's property, add

Visible='<%# Eval(flag) == 1%>'
Sign up to request clarification or add additional context in comments.

Comments

0

On the button I set the visible to true or false if the my_flag was of a particular value

<asp:Button ID="btnSwitchOff" CssClass="btn btn-warning" runat="server" Text="Switch Off" Visible='<%# Eval("my_flag").ToString() == "0" ? true : false%>' />

<asp:Button ID="btnSwitchOn" CssClass="btn btn-info" runat="server" Text="Switch Off" Visible='<%# Eval("my_flag").ToString() == "1" ? true : false%>' />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.