Search code examples
asp.netvb.netgridviewdata-binding

ASP.NET Code Delimiters return blank on load


I have a GridView with a TemplateField column that has an asp:Button in the ItemTemplate. The text of the button is <%# Bind("Active") %> while the datasource selectcommand is

"SELECT col1, col2, col3, CASE WHEN [Active] = 'true' THEN 'Active' ELSE 'Inactive' END AS [Active] FROM table

I want to change the CssClass of the button to one thing when the text says "Active" and set the CssClass to something else when it says "Inactive". Yet when I debug the GridView registers "" for the Cell on load. Right now my IF check is in the RowDataBound event. Does it need to be in a different event?


Solution

  • added the code in the RowDataBound event rather than switching the value of CssClass