Solved

How to intialize dropdownlist with Session variable in a formview control

Posted on 2009-04-05
2
908 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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