[ 来源:www.it55.com | 作者: | 时间:2007-07-15 | 收藏 | 推荐 ] 【大 中 小】
1 、绑定DropDownList:
| 以下为引用的内容: ddl_language.DataSource = createDataSource(); ddl_language.DataTextField = "languageTextField"; ddl_language.DataValueField = "languageValueField"; ddl_language.DataBind(); |
2、上面用到的createDataSource()方法: 45398 www.it55.com it55学习IT知识,享受IT生活 4dfkjn
| 以下为引用的内容: 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 DataSet lanDS = new DataSet(); string filePath = ConfigurationSettings.AppSettings["LanguageXmlFile"]; lanDS.ReadXml(filePath); if(lanDS.Tables.Count > 0) IT资讯之家 www.it55.com { foreach(DataRow copyRow in lanDS.Tables[0].Rows) { dt.ImportRow(copyRow); } } DataView dv = new DataView(dt); return dv; } |
3、Web.config
IT资讯之家 www.it55.com
| 以下为引用的内容: <appSettings> <!--The file path for the language type xml file--> <addkey="LanguageXmlFile"value="d:\Rhombussolution\Rhombus2\Languages.xml"/> </appSettings> |
vd;k;l www.it55.com rdfg
4、Languages.xml
www.it55.com
| 以下为引用的内容: <?xmlversion="1.0"encoding="utf-8"?> |
来源:网络
sflj www.it55.com kg^&fgd
(编辑:IT资讯之家 www.it55.com)