C# Want To Switch On Enums?

Jul 2, 2010

I have an enum:

public enum Status
{
Incomplete = 1, Complete = 2, Cancelled = 3, Deleted = 4
}

Now on a certain page I wish to list this enum in a checkboxlist. This would be fine except that I want the text of each checkbox to display different text than the enum.

i.e the check boxes should say:"Not Processed" instead of "Incomplete"

"Processed" instead of "Complete"

"Void" instead of "Cancelled"

Is it possible to put this enum in a foreach and then switch on the status and update the text. Like so:var statuses = Enum.GetNames(typeof(Status));
foreach (var status in statuses)))
{
switch (status) [code]....

View 3 Replies


Similar Messages:

Architecture :: Option To Using Enums And Switch Statements?

Oct 26, 2010

Is there any design pattern or architectural design that prevent the following type of code, where I have an enum with different fileformats and I have to make a switch anywhere I want to distinguish between the different fileformats?

[Code]....

If add an item to the enum definition in this case I have to change all the code that uses switches and that kind og enum which, I guess, is a bad approach in terms on maintenance of the application?

View 1 Replies

How To Use Enums In Project

May 15, 2010

i heard that Enums are very useful while we are developing the Project.

View 25 Replies

Architecture :: SQL Tables Or Enums Or Both?

Nov 12, 2010

I have a design question about whether to use sql tables or enums or both for a application I am developing for work.

Example - Gallery

Let say you have a database for displaying albums and photos. You want the ability to allow the user to set the display mode for the photos differnently in their albums i.e. LightBox, Scrolling, Single

Do you create an enum for DisplayModes so you can for example:

[Code]....

But then for reporting and admin you need to know the Album DisplayMode, so do you then have a SQL Table that just repeats the values of the enum?

View 3 Replies

MVC :: Forms Authentication (with Enums)?

Oct 25, 2010

Up until now I've been using the Session object to store the currently logged on user and using a strongly typed wrapper class to access it. I've been reading up on using the Session object in MVC, and it seems frowned upon (especially for user authentication), so I want to look at using forms authentication instead, but I'm not quite sure how to use it.


One issue I have is that I validate a user's permission level using an enum, whereas all the examples on forms authentication I've found use a "roles" object which is just a string. Can I still implement it using enums?

View 1 Replies

Overloading Enums And Properties In VB.NET?

Sep 23, 2010

I have a base class with the the following enum and property:

Public Enum InitType
Focus = 0
Help = 1
ErrorToolTip = 2
End Enum

[Code]....

First off, how do I do this - is it by simply overloading it? And secondly will my original property pick up the new enum automatically when using the derived class or will I need to overload that too?

View 1 Replies

Web Forms :: Using Enums In Global.asax>?

May 4, 2010

I was given a web app written in VB.net. I am using VS2008. The project has a Global.asax page with Enums declared

Example:Public Enum eCurrentLoc as Integer

Admins

AdminTools

Home

LogIn

Status

End Enum

But in the web application itself I get errors on this line of code:

Ads = Global.eCurrentLoc.Admins

I get the blue scwigly line under Global.eCurrentLoc

The error states 'eCurrentLoc' is not a memeber of '<Defaults>'

View 1 Replies

Web Forms :: Bitwise Operations Using Enums

Dec 22, 2010

I have a page which is accessible only from Monday to Friday. If i try to open it on Saturday or Sunday it shouldn't.I have a column in my DB naming WorkingDays and iam storing Bitwise value

Monday=1,Tuesday=2,Wednesday=4,Thursday=8....

So the value in my DB is 31 which is equal to Monday to Friday.If i open the page on saturday how should i check?

How should i convert todays day to bitwise value and how should i compare with the DB value.

View 12 Replies

Geting String From Integer Using Enums?

Oct 6, 2010

The .NET Framework contains an Enum called DayOfWeek.so now if i have an integer 7how can i ge the string "Saturday" using the enum?

View 1 Replies

Web Forms :: Enums And Checkboxlist / How To Insert The Selected Items To A List

Jan 27, 2011

i defined an enum with the [flags] attribute and binded it to a checkboxlist.

my question is how can i insert the selected items to a list?

this is my code:

[Code]....

View 4 Replies

Configuration :: .net 4 Switch To .net 3.5?

Mar 1, 2011

i built web site in asp4/.net 4 using vs2010

only to find out that the hoster that i need to use (rackspace) doesn't support .net 4 except in beta

of course i can't precompile in 3.5 because of some of the assemblies

any quick way to rebuild in 3.5 without totally rebuilding the whole site in 3.5?

View 2 Replies

Switch Statement Not Working?

May 20, 2010

My switch is based on a string, the text value of an server control. code:

[Code]....

[Code]....

View 3 Replies

AJAX :: How To Switch From IFrame App

Mar 3, 2010

1) Should I change the iframe to a User/Server control? or just a div?

2) I currently just have HTML links with load my iframe based on the page the user wants to see. How should I load (1) from the main links?

3) I have multiple levels of user controls. So control A could dynamically load Child controls...which each of those could load child controls. Do All these controls get a scriptManagerProxy? WHere should the original scriptManager go from (1)?

View 1 Replies

MVC :: Switch A Stylesheet On Postback?

Mar 4, 2011

I am new to MVC so I would like to know how would you switch the stylesheet of the view on postback?

I know how to do this in webforms but in MVC it does not appear to be done the same way.

View 2 Replies

C# - C# Switch Statement With A Combo Box?

Jan 28, 2011

currently i'm attempting to using a switch statement to change between time zone with a project for school.

if (extTime1.timeZone == "CDT")
{
switch (cboTimeZone.SelectedItem.ToString)
{
case "EST":

[Code]....

I can't seem to get the cboTimeZone to work correctly. I always thought SelectedItem was the correct choice in this situation.

View 2 Replies

Should Switch To IIS7 URL Rewriting

Mar 5, 2010

I'm using Intelligencia url rewriting currently but have just leased an IIS 7.5 server to put my asp.net 3.5 site on. I installed the IIS URL rewriting module and was amazed at how easy it was to create rules. Creating rules with the Intelligencia url rewriter is complicated (at least for me). Are there any downsides to switching? Is there a reason for me not to move on to the Microsoft solution? This site isn't live yet, so I have time to switch

View 2 Replies

Site Uses Cookies - Need To Switch To Sessions

Nov 17, 2010

My site uses cookies. I need to have it use sessions instead. The reason for this is because there is a third party that needs to connect to it, and it's always requiring 3rd party cookies to be enable in the browser and that is annoying my customers. Is there any other way around this other than switching to sessions?

View 4 Replies

How To Switch Radio Button To Yes Or No Without Selection

Aug 13, 2010

I am writing a condition like:

if (dt > 0) {
objinvoice.editInvoice(strInvoice, strRenew, strExpiry);
GridView1.EditIndex = -1; bindGrid(); }

I will have a radio button in gridview if that radiobutton is initially set to false and if the condition is true I would like to set it to true.

View 1 Replies

Security :: How To Switch To Another User Account

May 30, 2010

I have used membership provider to implement my system. The system administrator can list the users. What I want to do is, administrator should be able to sign-in as the selected user. I can sign out administrator by FormsAuthentication.Signout but how can I sign in as the selected user? Passwords are hashed so I can not retrieve the passwords.

View 5 Replies

Web Forms :: How To Switch Between 2 Images With An Interval Of 1 Second

Jan 21, 2011

I wonder how it will be possible to have an imagebutton to switch between Image1.jpg and Image2.jpg with an interval of 1 second. It will loop like this Image1.jpg,Image2.jpg,Image1.jpg all the time.

For example in this case, the images will start switch if the public variable blinkImage is "true".

[Code]....

View 6 Replies

Web Forms :: Switch CSS File From Code-behind?

Mar 22, 2010

I'm trying to switch CSS files in codebehind dependent upon which panel is exposed. I've read a number of sites that illustrate the process, but for some reason the code below is not working. The path to the css files are correct.

Also, my site uses a masterpage.

[Code]....

View 3 Replies

WCF / ASMX :: How To Automatically Switch Binding

Aug 13, 2010

I have a wcf service which is running on IIS7 using WsHttpBinding but further requirement I need to create another end point using NetTCPBinding.And I want to host my wcf service like if my client application in intranet it will use NetTcpBinding or if it is in internet then it will use WSHttpBinding.

View 3 Replies

Web Forms :: Switch Between Two Master Pages?

Oct 28, 2010

i have tow master pages .i want to switch between them according to a some condition

i work with this code to load master page what i want

at every page

[Code]....

i wirite this code for every page in my application

how can i write this code only once such as in Global.asax

View 5 Replies

SQL Server :: Switch Two Field Data?

Dec 16, 2010

I pulled a fast one today. I imported thousands of records and accidentally put the FName in the LName and the LName in the FName. I don't have a clue how to write a SQL or TSQL that will switch them. I do have a parameter for the SQL though. WHERE User - System Import.on ASP.NET because this is my place for help instead of going elsewhere to a more specific type of forum just for SQL. I do only ASP.NET VB/CS development so this is my home to find all my answers. (99% of the time).

View 10 Replies

C# - Switch .NET Assembly For Execution Of One Method?

Jan 20, 2010

I have different versions of dlls for my .NET application and most of the time I want to use the latest one. However, there is one method which I run on a separate thread where I need to be able to select an older version of the dll based on some criteria.

I have learned that it is not possible to just load an assembly and then unload it within the default application domain (I can't just keep both versions loaded because then I'm running into duplicate definitions of types problem)

Probably I have to create a separate AppDomain, load the assembly there and then unload it. This application domain would execute just one method on a separate thread and would work with a different version of the library.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved