Displaying Text For a Data Value
I am developing a reporting application in Visual Studio 2010 written in C# and I am trying to figure out how to add text into columns when the data is a certain value. For example, I have a variables column (with values 1-5), and I am wanting the report to display text instead of the numeric values (like: When the value is 1 the report will show Wind Speed, 2 - Temperature, etc.).

Sam HobbsRank #107 · 20.5K reputationPosted Mar 7, 2011, 7:23 AM EST
Amruta Kirdat72 reputationPosted Mar 1, 2011, 6:07 PM EST
if your text values are fixed for specifice numbers like 1 is always Wind Speed,2-Temperature etc den u c directly write code to display data :
if(intVariable == 1)
{
messagebox.show("Wind Speed");
}
else if(intVariable == 2)
{
messagebox.show("Temparature");
}
Sam HobbsRank #107 · 20.5K reputationPosted Mar 1, 2011, 7:30 PM EST
Andrew Fannin15 reputationPosted Mar 2, 2011, 11:15 AM EST
--Update--
I have found a way to do this using a Switch statement for each column as an expression, but I want to do this with bound data so this will not be data specific.
Sam HobbsRank #107 · 20.5K reputationPosted Mar 2, 2011, 12:19 PM EST
Rajesh S108 reputationPosted Mar 3, 2011, 4:53 AM EST
you can get it from datasource itself for example
select case when columnname1= 1 then 'Wind Speed' when columnname1=2 then 'Temperature' when columnname1=3 then 'your value' when columnname1=4 then 'your value' end as 'AliasName',columnname2,columnname3 from tablename
i hope it help you
Suthish NairRank #92 · 22.8K reputationPosted Mar 3, 2011, 8:44 AM EST
Andrew Fannin15 reputationPosted Mar 7, 2011, 5:31 AM EST