Search code examples
asp.netgridviewcheckboxevalitemtemplate

Bind String to CheckBox Checked


I have a gridview which is bound to a dataset loaded at page_load. The data consists of seven fields, three of which are hidden on the grid, the other four visible. The last three columns come from the database as strings, and will be either 'TRUE' or 'FALSE'. When using a bound column, they bound to the checkbox without any issues, but due to some changes to my code following a different question, I have changed them to TemplateFields and had to change the Checked property of the control to:

Checked='<%# Eval("FieldName").ToString().Equals("TRUE") %>'  

It works, but just wanted to check that this is the best way to bind these fields?


Solution

  • With a TemplateField, I believe that's just fine.