creating DropdownList

后端 未结 2 1404
刺人心
刺人心 2021-01-29 02:08

Consider the following XML file:

   
            
              
             


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 02:15

    How about this?

            XmlDocument doc = new XmlDocument();
            doc.Load(@"~/XML/XML.xml");
            var nodes = doc.SelectNodes("warehouse/cat[@id='computer']/item/SN");
    
            myDropDown.DataTextField = "InnerText";
            myDropDown.DataValueField = "InnerText";
    
    
            //now bind the dropdownlist to the dataview
            myDropDown.DataSource = nodes;
            myDropDown.DataBind();
    

提交回复
热议问题