if the strings are static (will not add / delete by the user ) then the easiest way is to create a List<> or an array for the strings and a small extension method like this
string[] m = new string[] { "Guest", "Admin", "Operator", "Unit Manager", "User" }
/// <summary>
///
/// </summary>
/// <param name="m">the string array which searches for the integer criteria.</param>
/// <param name="s"> the int32 number which will pass to the index of the array </param>
/// <returns></returns>
public static string IntToString( this string S, string[] m, int s)
{
string z = m.ElementAt(s);
//Array.Clear(m, 0, m.Length);
/// if you will need to clear the string array elements each using of this method then delete the comment slashes in front of the Array.Clear() method
/// in Array.Clear method also -to depends of your need- you can disable to show the
/// Array elements.. May be you will need only 1 admin and if an admin chooosen you can delete this option by changing the parameters of Array.Clear() Method
return z;
}
and a simple usage example in a Data Access Layer class :
string g;
if (dataReader["yourIntValueFromTable"] != DBNull.Value)
{
yourClassObject.yourIntValueFromTable = (int)dataReader["yourIntValueFromTable"];
yourClassObject.yourStringValue = g.IntToString(m, ((int)dataReader["yourIntValueFromTable"]));
}
after fill this class you can set as datasource to wherever you want.
but, if your strings are dynamic then you need to create a Stored Proc and call your values from there