Sri Lanka .NET 
       Forum Member

Monday, November 10, 2008

Loop through Enums in C#

option 01
public enum myEnum
{
Enum01= 1,
Enum02= 2,
Enum03= 3
};

foreach (typeof(myEnum) item in myEnum)
{
ddl.Items.Add(item.null,eventhandler)
}

option 02
if you want to bind DropDownList to Enum
then this is what you need

myDropDownList.DataSource = Enum.GetNames( typeof( MyEnum ) );
myDropDownList.DataBind();

or like that

foreach (string item in Enum.GetNames(typeof(MyEnum)))
{
int value = (int) Enum.Parse( typeof(MyEnum), item );
ListItem listItem = new ListItem( item, value.ToString() );
ddl1.Items.Add( listItem );
}


option 03
foreach ( string s in Enum.GetNames(typeof(MyEnum)) )
{
whatever.add(s);
}

More on:
http://msdn2.microsoft.com/en-us/library/system.enum(VS.71).aspx

Thursday, May 08, 2008

How do I… Uninstall Microsoft Internet Explorer 7?

How do I… Uninstall Microsoft Internet Explorer 7?

http://blogs.techrepublic.com.com/window-on-windows/?p=680

Wednesday, April 30, 2008

SELECT/DropDown Box Free Layer

Select /dropdown box overlapping with your div tags ?
Solution with CSS.
http://www.hedgerwow.com/360/bugs/css-select-free.html

Solution with JavaScript
http://xlib.wordpress.com/2006/04/12/bug-fix-select-box-displayed-through-dynamic-div-in-internet-explorer/

Monday, December 17, 2007

Give me a break

 

I got this nice/funny/interesting mail from one of my best friends Ramesh!

Thought of share this interesting mail with others.

 

MY Dear ON-LINE FRIENDS,

I want to thank all my friends and other unknown people who have forwarded chain letters to me in 2003, 2004, 2005, 2006, 2007 & YOU because of your kindness.

I stopped drinking Coca-Cola after I found out that it's good only for removing toilet stains.

I stopped going to the movies for fear of sitting on a needle infected with AIDS.

I stopped using my ATM card because I am afraid that someone might have installed a small device on the ATM machine that will stole my ATM card number and my pin number when typing it.

I smell like a wet dog since I stopped using deodorants because they cause cancer.

I don't leave my car in the parking lot or any other place and sometimes I even have to walk about 7 blocks for fear that someone will drug me with a perfume sample and try to rob me.

I also stopped answering the phone for fear that they may ask me to dial a stupid number and then I get a phone bill from hell with calls to Uganda, Singapore and Tokyo.

I also stopped drinking anything out of a can for fear that I will get sick from the rat faeces and urine.

When I go to parties, I don't look at any girl, no matter how hot she is, for fear that she will take me to a hotel, drug me, then take my kidneys and leave me taking a nap in a bathtub full of ice.

I also donated all my savings to the Amy Bruce account. A sick girl that was about to die in the hospital about 7,000 times. (Poor girl! she's been 7 since 1993...)

I went bankrupt from bounced checks that I made, expecting the $15,000 that Microsoft and AOL were supposed to send me (when I participated in their special-mail program) would arrive soon.

My free Nokia phone never arrived and neither did the free passes for a paid vacation to Disneyland.

Still open to help someone from Bulgaria who wants to use my account to transfer his uncle's property of some hundred millions $.

Made some Hundred wishes before forwarding those Dalai Lama, most of those "Wishes" are already married (to someone else)

IMPORTANT NOTE: If you do not send this e-mail to at least 913760 people in the next 10 seconds, a bird will sh*t on your head today at 04.00 p.m.

Now give me a break !!!

MSSQL Select Top 10 and Next 10 (fwd ...n)

The following query will emulate a

SELECT emp_id,lname,fname FROM employee LIMIT 20,10

That says, give me 10 records starting at record 21. So what will be
returned are rows 21-30. This is used heavily in web-based apps so you can
do recordset paging.

Here is what you can do in MS SQL to emulate it (this runs on the PUBS
db):

select * from (
select top 10 emp_id,lname,fname from (
select top 30 emp_id,lname,fname
from employee
order by lname asc
) as newtbl order by lname desc
) as newtbl2 order by lname asc

The main thing to remember is to deal with all your ORDER BY clauses and
also to use the inner TOP as the sum of what you are looking for. In this
example - 30 since you start at 20 and want 10 rows (20+10=30).

Hope this helps you as it has helped me improve performance greatly on my
web-based apps since I no longer have to transfer loads of data across the
wire to get just the 10 results I display on a page.

Don't even think about using the internal ADO paging stuff if you have a
lot of records to deal with, it will kill your performance as it must pull
the entire recordset down to the local machine before it can do its work.
Why bring down 20,000 records if you only want to display 10?

Wednesday, December 12, 2007

6 Truths of Life.


1.  You cannot touch all your teeth with your tongue.
2.  All idiots, after reading the first truth try it.
3.  The first truth is a lie.
4.  You're smiling now because you're an idiot.
5.  You soon will forward this to another idiot.
6.  There's still a stupid smile on your face.

Monday, November 26, 2007

Get only one ( top most) record from relation table.

select
(select flightnumber as fn
from routing r
where r.involvedinformationid=ii.id
and r.id=(select MIN(id) from routing where involvedinformationid=r.involvedinformationid)),ip.*, ii.*
from involvedperson ip left outer join involvedinformation ii on ip.id=ii.involvedpersonid
where ip.emergencysituationcaseid=561

Wednesday, August 22, 2007

PEOPLE WONDER WHY THE CALL CENTRE GUYS R PAID SO MUCH.

PEOPLE WONDER WHY THE CALL CENTRE GUYS R PAID SO MUCH......FOR JUST BEING
ON THE PHONE.
TAKE A LOOK:
1 ) Tech Support : "I need you to right-click on the Open Desktop."
Customer : "Ok."
Tech Support : "Did you get a pop-up menu?"
Customer : "No."
Tech Support : "Ok. Right click again. Do you see a pop-up menu?"
Customer : "No."
Tech Support : "Ok, sir. Can you tell me what you have done up until this
point?"
Customer : "Sure, you told me to write 'click' and I wrote 'click'."
           ----------------------------------------
2) Customer : "I received the software update you sent, but I am still
getting the same error message."
Tech Support : "Did you install the update?"
Customer: "No. Oh, am I supposed to install it to get it to work?"
      --------------------------------------------------
3)Customer : "I'm having trouble installing Microsoft Word."
Tech Support : "Tell me what you've done."
Customer : "I typed 'A: SETUP'."
Tech Support : "Ma'am, remove the disk and tell me what it says."
Customer : "It says '[PC manufacturer] Restore and Recovery disk'."
Tech Support : "Insert the MS Word setup disk."
Customer : "What?"
Tech Support: "Did you buy MS word?"
Customer: "No..."
      --------------------------------------------------
4).Customer : "Do I need a computer to use your software?"
Tech Support : ?!%#$ (welll pretend to smile)
      --------------------------------------------------
5). Tech Support : "Ok, in the bottom left hand side of the screen, can you
see the 'OK' button displayed?"
Customer : "Wow. How can you see my screen from there?"
Tech support : ##### ***
      --------------------------------------------------
6) Tech Support : "What type of computer do you have?"
Customer : "A white one."
Tech support : ******_____####
      --------------------------------------------------
7). Tech Support : "What operating system are you running?"
Customer : "Pentium."
Tech support : ////-----+++
      --------------------------------------------------
8). Customer : "My computer's telling me I performed an illegal abortion."
Tech support : ??????
      --------------------------------------------------
9)Cus tomer : "I have Microsoft Exploder."
Tech Support : ?!%#$
      --------------------------------------------------
10). Customer : "How do I print my voicemail?"
Tech support : ??????
      --------------------------------------------------
11). Customer : "You've got to fix my computer.. I urgently need to print
document, but the computer won't boot properly."
Tech Support : "What does it say?"
Customer : "Something about an error and non-system disk."
Tech Support : "Look at your machine. Is there a floppy inside?"
Customer : "No, but there's a sticker saying there's an Intel inside."
Tech support : @@@@@
      --------------------------------------------------
12). Tech Support: "Just call us back if there's a problem. We're open 24
hours."
Customer: "Is that Eastern time?"
      --------------------------------------------------
13). Tech Support : "What does the screen say now?"
Customer : "It says, 'Hit ENTER when ready'."
Tech Support : "Well?"
Customer : "How do I know when it's ready?"
Tech support : *** ---- ++++
      --------------------------------------------------
The best of the lot
14). A plain computer illiterate guy rings tech support to report that his
computer is faulty.
Tech: What's the problem?
User: There is smoke coming out of the power supply.
Tech: (keep quite)
Tech: You'll need a new power supply.
User: No, I don't! I just need to change the startup files.
Tech: Sir, the power supply is faulty. You'll need to replace it.
User: No way! Someone told me that I just needed to change the startup and
it will fix the
problem! All I need is for you to tell me the command.
Tech support::
10 minutes later, the User is still adamant that he is right. The tech is
frustrated and fed up.
Tech support:: (hush hush)
Tech: Sorry, Sir. We don't normally tell our customers this, but there is
an undocumented DOS
command that will fix the problem.
User: I knew it!
Tech : Just add the line LOAD NOSMOKE.COM at the end of the CONFIG.SYS. Let
me know how it goes.
10 minutes later.
User : It didn't work. The power supply is still smoking.
Tech : Well, what version of DOS are you using?
User : MS-DOS 6.22 .
Tech : That's your problem there. That version of DOS didn't come with
NOSMOKE. Contact Microsoft and ask them for a patch that will give you the
file. Let me know how it goes.
1 hour later.
User : I need a new power supply.
Tech support : How did you come to that conclusion?
Tech support : (hush hush)
User : Well, I rang Microsoft and told him about what you said, and he
started asking questions about the make of power supply.
Tech: Then what did he say?
User: He told me that my power supply isn't compatible with NOSMOKE.
       -------------------------------------------------
Hight Of all (Too Good)
15) customer care officer: I need a product identification number right now
and may I help u in
finding it out?
Cust: sure
CCO: could u left click on start and do u find 'My Computer'?
Cust: I did left click but how the hell do I find your computer?