GridView Text Value Mapping - ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cday119
    New Member
    • Mar 2008
    • 29

    GridView Text Value Mapping - ASP.NET

    Hey Everyone,

    I have a SqlDataSource hooked into a gridview. In the database I have a boolean property. It shows up in the gridview as true but I want to say something else. What is the best way to set if row.cell(0).tex t = "True" row.cell(0).tex t = "Finished"

    Kind of like drop down list has a value text mapping.

    Thanks
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    I'm assuming that you are writing in ASP.NET, since "classic" ASP does not support gridviews. I have moved your post to the .NET forum because the ASP forum is for "classic" ASP only.

    Anyway, I think you are looking for a ivalueconverter , hopefully a .NET expert can clarify.

    Jared

    Comment

    • mldisibio
      Recognized Expert New Member
      • Sep 2008
      • 191

      #3
      There IS a way to handle this, but I have been away from ASP.Net so long I will let someone else answer directly. Nonetheless, I wanted to throw out another approach, if it works for you:

      If the data is basically display only, can you change the sql which pulls it? This would solve your problem before it gets to the Grid.

      Assuming your source column in SqlServer is a bit, then you can pull that column like this (call it col2):
      Code:
      SELECT
       col1 as FirstColumn,
       CASE col2 
         WHEN 0 THEN 'Unfinished'  ELSE 'Finished' 
       END as SecondColumn
      FROM MyTable
      Again, you may not be able to change the sql, or you may not want to for other design reasons. Just a suggestion.

      Comment

      Working...