Solved

How to intialize dropdownlist with Session variable in a formview control

Posted on 2009-04-05
2
901 Views
Last Modified: 2013-12-17
Hi,

   I have one question on asp.net formview control.
I have a formview control on my webpage. It has a dropdown list. I am populating it with data coming from database. Also, the dropdown list should have one more value in the list which is coming from session variable(from another page) and that should be the default value for the ddlist. I can populate the dropdown vid the data from database. But i donno how to add the session value in the dropdown list.
 Can i have suggestions.

Thanks
0
Comment
Question by:dotnetuser07
  • 2
2 Comments
 
LVL 4

Expert Comment

by:y0usuf
ID: 24074284
After binding dropdownlist from database.
You can add the item from session by

dropdownlist.items.add(new listItem(session("DropDowlistItemToAddText"),session("DropDowlistItemToAddValue")))
0
 
LVL 4

Accepted Solution

by:
y0usuf earned 250 total points
ID: 24074288
Or you can also use AppendDataItems=True Property of dropdownlist

If you do this FIrst Add the Session item to the dropdownlist
dropdownlist.items.add(new listItem(session("DropDowlistItemToAddText"),session("DropDowlistItemToAddValue")))

And then bind the dropdownlist from database
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now