Populating dropdown from the XML in C#

后端 未结 5 2166
花落未央
花落未央 2021-01-06 06:00

I have got below xml format with me and I am using .NET 2.0.



  

        
5条回答
  •  被撕碎了的回忆
    2021-01-06 06:12

    Maybe this can work for you:

    path = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, @"App_Data\Empresas.xml");
    ds = new DataSet();
    ds.ReadXml(path);
    ddlEmpresa.DataValueField = "value";
    ddlEmpresa.DataTextField = "name";
    ddlEmpresa.DataSource = ds;
    ddlEmpresa.DataBind();
    

    and the XML is:

    
     
        
          Elemento 1
          1
        
      
    

提交回复
热议问题