1. Bind dropdownlist:
Ddl_language.datasource = createdatasource ();
Ddl_language.datatextfield = "languagetextfield ";
Ddl_language.datavaluefield = "languagevaluefield ";
Ddl_language.databind ();
2. The createdatasource () method used above:
Private icollection createdatasource () {// create a data table to store the data for the ddl_langauge control datatable dt = new datatable (); // define the columns of the table DT. columns. add ("languagetextfield", typeof (string); DT. columns. add ("languagevaluefield", typeof (string); // read the content of the XML file into a dataset lands = new dataset (); string filepath = configurationsettings. appsettings ["languagexmlfile"]; lands. readxml (filepath); If (lands. tables. count> 0) {foreach (datarow copyrow in lands. tables [0]. rows) {DT. importrow (copyrow) ;}} dataview DV = new dataview (DT); Return DV ;}3. Web. config
<Deleetask> <! -- The file path for the language type XML file --> <addkey = "languagexmlfile" value = "D: \ fig \ Fig 2 \ ages. xml"/> </FIG>
4. Ages. xml
<? Xmlversion = "1.0" encoding = "UTF-8"?> <Shortagetypes> <language> <shortagevaluefield> en-US </shortagevaluefield> <shortagetextfield> English </shortagetextfield> </language> <shortagevaluefield> ZH-CN
From: http://dev.csdn.net/author/guoshaohong/ee27abbe9e874a2f837d47d5916db4a4.html