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 HobbsPosted Mar 7, 2011, 12:23 PM
Andrew FanninPosted Mar 7, 2011, 10:31 AM
Suthish NairPosted Mar 3, 2011, 1:44 PM
Rajesh SPosted Mar 3, 2011, 9:53 AM
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
Sam HobbsPosted Mar 2, 2011, 5:19 PM
Andrew FanninPosted Mar 2, 2011, 4:15 PM
--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 HobbsPosted Mar 2, 2011, 12:30 AM
Amruta KirdatPosted Mar 1, 2011, 11:07 PM
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");
}