How to bind the Status
type Columns with the grid view using ENUM & Dictionary
Step 1:- Create one class with enum and Dictionary
namespace Utility
{
public static class Constants
{
public enum ConstantStatus
{
[Description("New")]
New = 0,
[Description("In
process")]
Inprocess = 1,
[Description("Completed")]
Completed = 2,
};
public static Dictionary<int, string> StatusDictionary = new Dictionary<int, string>()
{
{0,"New"},
{1,"In process"},
{2,"Completed"}
};
}
}
Step 2:- In Grid
How to bind the
template field with enum and dictionary process.
ENUM
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%# Enum.GetName(typeof(Utility.Constants.ConstantStatus),Convert.ToInt32(Eval("Status"))) %>'></asp:Label>
</ItemTemplate>
Dictionary
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text=' <%#( Utility.Constants.StatusDictionary[Convert.ToInt32(Eval("Status"))]) %>'></asp:Label>
</ItemTemplate>
No comments:
Post a Comment