This is a migrated thread and some comments may be shown as answers.

binding to the opposite of a boolean

2 Answers 734 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tops Software
Top achievements
Rank 2
Tops Software asked on 22 Aug 2013, 04:41 PM
Hello,
This should be easy but I am struggling to find a solution. 

I have a radgrid with a custom edit form template I want to show one of the fields based on the opposite of a boolean field.
Something like this:

<tr id="trCloseDate" runat="server" visible='<%# Bind(!"j") %>'>

I dont think this would ultimately work though as I would need the user to be able to toggle at will. Something in the code behind would work better I think.

I have tried to do this in the code behind, using the onCheckChanged event but am running into issues as I cant find a way to get the tr control as it is not rendered yet, I believe, since it is later in the table.

Another weird side issue is that the checkbox is not showing the correct check if I use the changed event.

Thank you for your time.

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Aug 2013, 05:27 AM
Hello,

Please try with the below code snippet.

Visible='<%# Eval("j") == false ? true: false %>'

OR

Visible='<%# Convert.ToBoolean(Eval("j")) ? false: true %>'


Let me know if any concern.

Thanks,
Jayesh Goyani
0
Tops Software
Top achievements
Rank 2
answered on 23 Aug 2013, 03:40 PM
The second one was perfect.

I should have thought of that Thank you.
Tags
Grid
Asked by
Tops Software
Top achievements
Rank 2
Answers by
Jayesh Goyani
Top achievements
Rank 2
Tops Software
Top achievements
Rank 2
Share this question
or