If we want to bind a simply sort of data to the dropdownlist or the ListBox, it better if we can use a XML document and a XmlDataSource. Also, we can set the path of the xml file to the Resource and set the "DataFile" protery of the XmlDataSource control
with the Resource object.
Please refer below link for more information on how to fetch values from XmlDataSource and bind it to the dropdown-
gauravggn
Member
4 Points
48 Posts
Binding a drop down from Resource File
Nov 11, 2009 10:26 AM|LINK
I have a resource file which has about 300 values
I want drop downlist to pick these values in one go instead of adding one by one like this:
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">DropDownList1.Items.Add(Resources.Strings.Color1);</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> DropDownList1.Items.Add(Resources.Strings.Color2);</div>DropDownList1.Items.Add(Resources.Strings.Color1);
DropDownList1.Items.Add(Resources.Strings.Color2);
....Colo300
any solution for this please help
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Binding a drop down from Resource File
Nov 11, 2009 10:53 AM|LINK
Hi,
find the key and then try
string s = (string)GetLocalResourceObject("myKey");
ListBox1.Items.Add(new ListItem(s));
http://forums.asp.net/p/1489229/3503539.aspx
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
leena.d.pati...
Member
430 Points
79 Posts
Re: Binding a drop down from Resource File
Nov 11, 2009 10:53 AM|LINK
Hi,
If we want to bind a simply sort of data to the dropdownlist or the ListBox, it better if we can use a XML document and a XmlDataSource. Also, we can set the path of the xml file to the Resource and set the "DataFile" protery of the XmlDataSource control with the Resource object.
Please refer below link for more information on how to fetch values from XmlDataSource and bind it to the dropdown-
http://www.codeproject.com/KB/combobox/LocalizaleDropdown.aspx
Hope it will help.
Leena
Please remember to mark replies as answers if you find them useful.