首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

Asp.net加XML有关问题

2011-12-11 
Asp.net加XML问题?strResultInfowebMail.GetDepartment(userId,doMain,account,sign)strResultInfo返回

Asp.net加XML问题?
strResultInfo=webMail.GetDepartment(userId,doMain,account,sign);

  strResultInfo返回值为:
  <?xml version="1.0" encoding="GB2312" ?> 
- <departmentList>
- <department>
  <departmentId>2</departmentId> 
  <domainId>224556</domainId> 
  <departmentName>人力资源</departmentName> 
  <description>人力资源</description> 
  <depId>0</depId> 
  <rank>null</rank> 
  <type>null</type> 
  <top>0</top> 
  <resv1>0</resv1> 
  <resv2>renliziyuan</resv2> 
  </department>
- <department>
  <departmentId>3</departmentId> 
  <domainId>224556</domainId> 
  <departmentName>财务</departmentName> 
  <description>null</description> 
  <depId>0</depId> 
  <rank>null</rank> 
  <type>null</type> 
  <top>1</top> 
  <resv1>null</resv1> 
  <resv2>null</resv2> 
  </department>
  </departmentList>

  #region XML

  XmlDocument xmlDoc = new XmlDocument();
  xmlDoc.LoadXml(strResultInfo);
  XmlNodeList mailList = xmlDoc.SelectNodes("/departmentList/department");

  //lblCount.Text = mailList.Count.ToString();

  for (int i = 0; i < mailList.Count; i++)
  {
  //这是DropDownList控件
  dlMailList.DataSource = strResultInfo;
  dlMailList.DataTextField = mailList[i].SelectSingleNode("departmentId").InnerText.ToString();
  dlMailList.DataValueField = mailList[i].SelectSingleNode("departmentName").InnerText.ToString();
  this.DataBind();
  }
我想实现把xml分别两个值(departmentId,departmentName)循环遍历绑定到DropDownList控件,可是报错误为:DataBinding:“System.Char”不包含名为“2”的属性。

[解决办法]
分别遍历...

热点排行