473,839 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Load DropDownList

Hello,

I have a list of entities (with properties Key and Description).

Which is the best manner of load dropdownlist with this list ?

Thanks in advance
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net

Apr 24 '07 #1
4 5687
The best manner is to databind the ddl to the list like this:

myDdl.DataSourc e = myList;
myDdl.DataTextF ield = "Descriptio n";
myDdl.DataValue Field = "Key";
myDdl.DataBind( );

You can do the same in the markup.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Alhambra Eidos Kiquenet" <Al************ *******@discuss ions.microsoft. com>
wrote in message news:D7******** *************** ***********@mic rosoft.com...
Hello,

I have a list of entities (with properties Key and Description).

Which is the best manner of load dropdownlist with this list ?

Thanks in advance
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net

Apr 24 '07 #2
Assuming you have the list in the form of array/datatable/arraylist:

DropDown.DataSo urce = <entity collection>;
DropDown.DataTe xtField = <entity property name for text display
(description)>;
DropDown.DataVa lueField = <entity property name for value (key)>;
DropDown.DataBi nd ();

"Alhambra Eidos Kiquenet" wrote:
Hello,

I have a list of entities (with properties Key and Description).

Which is the best manner of load dropdownlist with this list ?

Thanks in advance
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
Apr 24 '07 #3
I'd try but it appears the following error:

Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource.

My List of entities is a Dictionary<int, MyEntityObject> .
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net

"Siva M" wrote:
Assuming you have the list in the form of array/datatable/arraylist:

DropDown.DataSo urce = <entity collection>;
DropDown.DataTe xtField = <entity property name for text display
(description)>;
DropDown.DataVa lueField = <entity property name for value (key)>;
DropDown.DataBi nd ();

"Alhambra Eidos Kiquenet" wrote:
Hello,

I have a list of entities (with properties Key and Description).

Which is the best manner of load dropdownlist with this list ?

Thanks in advance
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
Apr 24 '07 #4
Assign DataSource property to Dictionary.Valu es, which has the desired
collection having your entities.

"Alhambra Eidos Kiquenet" wrote:
I'd try but it appears the following error:

Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource.

My List of entities is a Dictionary<int, MyEntityObject> .
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net

"Siva M" wrote:
Assuming you have the list in the form of array/datatable/arraylist:

DropDown.DataSo urce = <entity collection>;
DropDown.DataTe xtField = <entity property name for text display
(description)>;
DropDown.DataVa lueField = <entity property name for value (key)>;
DropDown.DataBi nd ();

"Alhambra Eidos Kiquenet" wrote:
Hello,
>
I have a list of entities (with properties Key and Description).
>
Which is the best manner of load dropdownlist with this list ?
>
Thanks in advance
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
>
Apr 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2815
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option Description"></asp:BoundColumn> <asp:TemplateColumn runat="server" HeaderText="Id Type Option" "> <itemtemplate> <asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TypeOption") %>' /> <asp:label runat="server" ID="LlbTypeOption" Visible=False...
3
828
by: Stanley J Mroczek | last post by:
I am trying to load a droplist in VB when the edit is clicked in a datagrid. I tried to use OnDataBinding and loading the droplist in subroutine "loaddd". I get this error Object reference not set to an instance of an object. Here is the code: <asp:TemplateColumn runat="server" HeaderText="Id Type Option" SortExpression="IdTypeOption"> <itemtemplate> <asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem,
1
1812
by: Stanley J Mroczek | last post by:
I am trying to load a dropdownlist in VB when the edit is clicked in a datagrid. How do i call Sub loaddd to load the dropdownlist <asp:TemplateColumn runat="server" HeaderText="Id Type Option" SortExpression="IdTypeOption"> <itemtemplate> <asp:label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TypeOption") %>' /> <asp:label runat="server" ID="LlbTypeOption" Visible=False Text='<%# DataBinder.Eval(Container.DataItem,...
9
21653
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter the results in the grid. Say you filter the grid for records that have a certain condition set to "NO" (in this case a checkbox). In this scenario the search returns one result. If I then check the checkbox ("YES") and save it, I now get my message...
18
2473
by: Julia Hu | last post by:
Hi, I have a datagrid, and in different rows I need to programmatically bind different type of controls and load data into these controls. For example,in the first row I need to bind data into a textbox, and in the second row I need to bind data into a dropdownlist...It all depends on the data I select from the database. I cannot use TemplateColumn because it has to be the same type of control for one column.
0
1004
by: Jim in Arizona | last post by:
When the page loads, a dropdownlist is populated from a table. I populate the DataTextField with a persons name, and the DataValueField with the ID of the table (the key field) for further processing. I also have another field, a bit field, that I need to process on load. Basically, when the dropdownlist is first populated (when the page is first visited), and if the first person that shows up in the the dropdownlist has a bit field in...
2
6977
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html and i am implementing it in my website....
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10908
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10587
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7829
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4487
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.