Enum Problem
-
I defined a enum as public enum Access { Guest = 1, Public = 2, Center = 4, Member = 8, Trader = 16 } there are 5 checkboxes in my asp.net page suppose user checked Guest and Center then Value of center and Guest i.e.(1+4=5) 5 will save in Database in integar field.. Now my Question is I am getting Value from database like categoriesDTO.CatAccess = (Access)r["CategoryStatus"]; Now enum has value 5... So how can i check these 2 checkboxes of center and Guest Thanx In advance
-
I defined a enum as public enum Access { Guest = 1, Public = 2, Center = 4, Member = 8, Trader = 16 } there are 5 checkboxes in my asp.net page suppose user checked Guest and Center then Value of center and Guest i.e.(1+4=5) 5 will save in Database in integar field.. Now my Question is I am getting Value from database like categoriesDTO.CatAccess = (Access)r["CategoryStatus"]; Now enum has value 5... So how can i check these 2 checkboxes of center and Guest Thanx In advance
You cannot! How you think you will make 5 into 4 and 1??? It could either be 2 and 3!! Save comma separated values like 1,4 in database and then fetch, split and use them. HTH
Coding C# ExciteTemplate
-
You cannot! How you think you will make 5 into 4 and 1??? It could either be 2 and 3!! Save comma separated values like 1,4 in database and then fetch, split and use them. HTH
Coding C# ExciteTemplate
Coding C# wrote:
How you think you will make 5 into 4 and 1???
Ever heard of bit flags?
only two letters away from being an asset
-
I defined a enum as public enum Access { Guest = 1, Public = 2, Center = 4, Member = 8, Trader = 16 } there are 5 checkboxes in my asp.net page suppose user checked Guest and Center then Value of center and Guest i.e.(1+4=5) 5 will save in Database in integar field.. Now my Question is I am getting Value from database like categoriesDTO.CatAccess = (Access)r["CategoryStatus"]; Now enum has value 5... So how can i check these 2 checkboxes of center and Guest Thanx In advance
-
Coding C# wrote:
How you think you will make 5 into 4 and 1???
Ever heard of bit flags?
only two letters away from being an asset
Hi all.. My question is Genuine.. Bcoz if stored value is 5 it means only 1 and 4 checkbox has to be checked. No other Chekbox make combination of 2 +3 bcoz 2 is a value but 3 is not there
-
Hi all.. My question is Genuine.. Bcoz if stored value is 5 it means only 1 and 4 checkbox has to be checked. No other Chekbox make combination of 2 +3 bcoz 2 is a value but 3 is not there
Sachin Dubey wrote:
My question is Genuine..
and so is my answer below
only two letters away from being an asset