当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: see title ......
 ·dropdownlist绑定数组    »显示摘要«
    摘要: count = (dropdownlist) skin.findcontrol("country"); count.datasource = getlanguage.getstringarr("item");//这里返回一个数组string[2][] count.datatextfield =;//绑定数组第一列 count.datavaluefie......


关于XML,DropDownList动态绑定的问题

<?xml   version="1.0"   encoding="UTF-8"?>  
  <root>  
  <CountryItem>  
  <Item   Value="CN">中国</Item>  
  <Item   Value="AM">美国</Item>  
  <Item   Value="JP">日本</Item>  
  <Item   Value="GE">德国</Item>  
  </CountryItem>  
  </root>  
  .DataTextField   绑定中文字  
  .DataValueField 绑定节点属性Value的值  
   
  如何写呢?

NO.1   作者: saucer

method   1:  
   
  System.Xml.XmlDocument   doc   =   new   System.Xml.XmlDocument();  
  doc.Load(Server.MapPath("YourXml.xml"));  
  foreach   (System.Xml.XmlNode   node   in   doc.SelectNodes("/root/CountryItem/Item"))  
  {  
  YourDropDown.Items.Add(new   ListItem(node.InnerText,node.Attributes["Value"].Value));  
  }  
   
  method   2:  
   
  System.Data.DataSet   ds   =   new   System.Data.DataSet();  
      ds.ReadXml(Server.MapPath("YourXml.xml"));  
       
  YourDropDown.DataSource   =   ds.Tables["Item"].DefaultView;  
  YourDropDown.DataTextField   =   "Item_Text";  
  YourDropDown.DataValueField   =   "Value";  
  YourDropDown.DataBind();  
   
 


 ·帮帮兄弟    »显示摘要«
    摘要: 如何在delphi中实现实时监控网络连通状态 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE