Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want display ststus column with values 1,2,3. Here
1 indicates Pending,2 indicates approved, and 3 indicates rejected.
But instead of displaying numbers in gridview how can I replace this with correspoding
words?
Posted
Updated 25-Mar-14 22:38pm
v2

Its simple you can use Case in your sql query.
here for example now iam using the field name as Status

SQL
Select Status, case When status =1 Then 'Pending'
When status =2 then 'approved'
When status =3 then 'rejected'
else 'noStatus' END as 'Status'
from 
TableName
 
Share this answer
 
Comments
Ni!E$H_WAGH 26-Mar-14 3:14am    
Thanks syed shanu
Use CASE in sql query
CASE column_name
  WHEN 1 THEN Pending
  WHEN 2 THEN Approved
  WHEN 3 THEN Rejected
END
 
Share this answer
 
Try:
SQL
SELECT CASE ststus
            WHEN 1 THEN 'Pending'
            WHEN 2 THEN 'Approved'
            WHEN 3 THEN 'Rejected'
            ELSE 'ERROR'
       END
FROM MyTable
 
Share this answer
 
VB
CASE Status  
    WHEN 1 THEN 'Pending'
    WHEN 2 THEN 'Approved'
    WHEN 3 THEN 'Rejected'
    ELSE 'You can put any error here'
END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900