This topic is locked
[SOLVED]

 How do I setup Checkbox with character Y/N column

7/24/2020 12:24:57 PM
ASPRunner.NET General questions
C
cboucher author

I have some legacy columns in my SQL Server tables that are char(1) and contain either Y or N. I would like to set the Edit As properties to a checkbox so this field can be updated with a checkbox on the Add and Edit pages. Is there a way to do this out of the box or do I need to create a custom edit plugin?
Thanks,

Craig

admin 7/24/2020

There multiple options here. The easiest is add the code to BeforeAdd/BeforeEdit events that would convert 0 and 1 values to Y and N.
The better option, of course, is to store data like in a numeric field in the database and convert it to Y or N on the fly, i.e. in the SQL Query.

C
cboucher author 7/25/2020

Thank you for the guiding this newbie. It was easy to get it working.
I added the following code to the "Process Record Values" event of both the Add and Edit pages:

values["Inactive"] = values["Inactive"] == "Y" ? 1 : 0;


Then I added the following code in the "Before Record added/updated" events of the Add and Edit pages:

values["Inactive"] = values["Inactive"] == 1 ? "Y" : "N";