Populate ListBox with XML Data?
-
Hi In my application, I have a ListBox which is to be filled with the values in XML file. My application goes like this..... I am getting a State name of USA from the QueryString, with the help of a that QueryString I have to get the Names of Counties of that State, which r in a XML file on to a ListBox. My XML File looks like this AK Alaska Aleutians East AK Alaska Aleutians West ..... ..... AL Alabama Autauga AL Alabama Baldwin ..... ..... GA Georgia Campbell GA Georgia Milton How can I get only County Names of a particular State for this XML file. Suggest me an Example. I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
-
Hi In my application, I have a ListBox which is to be filled with the values in XML file. My application goes like this..... I am getting a State name of USA from the QueryString, with the help of a that QueryString I have to get the Names of Counties of that State, which r in a XML file on to a ListBox. My XML File looks like this AK Alaska Aleutians East AK Alaska Aleutians West ..... ..... AL Alabama Autauga AL Alabama Baldwin ..... ..... GA Georgia Campbell GA Georgia Milton How can I get only County Names of a particular State for this XML file. Suggest me an Example. I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
XmlDataDocument xdoc = new XmlDataDocument(); XmlTextReader Reader = new XmlTextReader(server.MapPath("XML.xml")); xdoc.DataSet.ReadXml(Reader, XmlReadMode.InferSchema); ddl.datasource=xdoc.dataset; ddl.DataTextField="CountryName"; ddl.databind();
Best Regard Pathan---------------------------------------------------
-
XmlDataDocument xdoc = new XmlDataDocument(); XmlTextReader Reader = new XmlTextReader(server.MapPath("XML.xml")); xdoc.DataSet.ReadXml(Reader, XmlReadMode.InferSchema); ddl.datasource=xdoc.dataset; ddl.DataTextField="CountryName"; ddl.databind();
Best Regard Pathan---------------------------------------------------
Thank u Imran Khan Pathan for u reply. It is giving only the Counties of only one State i.e first in the list. I want to get Counties of different States with the help of a QueryString. Where I have to give this QueryString to get the Data for Different State's Counties
I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
-
Hi In my application, I have a ListBox which is to be filled with the values in XML file. My application goes like this..... I am getting a State name of USA from the QueryString, with the help of a that QueryString I have to get the Names of Counties of that State, which r in a XML file on to a ListBox. My XML File looks like this AK Alaska Aleutians East AK Alaska Aleutians West ..... ..... AL Alabama Autauga AL Alabama Baldwin ..... ..... GA Georgia Campbell GA Georgia Milton How can I get only County Names of a particular State for this XML file. Suggest me an Example. I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
use this code to bound ur dropdownlist anjoy the coding Dim _Doc As New System.Xml.XmlDocument _Doc.Load("file:///C:/testxml.xml") Dim NodeList As System.Xml.XmlNodeList = _Doc.SelectNodes("/USA/CountyUSA/CountyName") For Each node As System.Xml.XmlNode In NodeList Dim ss As String = node.InnerText DropDownList1.DataSource = ss DropDownList1.DataBind() Next
Piyush Vardhan Singh Programmer TAS NewDelhi India
-
use this code to bound ur dropdownlist anjoy the coding Dim _Doc As New System.Xml.XmlDocument _Doc.Load("file:///C:/testxml.xml") Dim NodeList As System.Xml.XmlNodeList = _Doc.SelectNodes("/USA/CountyUSA/CountyName") For Each node As System.Xml.XmlNode In NodeList Dim ss As String = node.InnerText DropDownList1.DataSource = ss DropDownList1.DataBind() Next
Piyush Vardhan Singh Programmer TAS NewDelhi India
where i stored CountyName in ss string. u store all CountyName in hash table or collection then bind drop down list(out side the for each)
Piyush Vardhan Singh Programmer TAS NewDelhi India
-
Thank u Imran Khan Pathan for u reply. It is giving only the Counties of only one State i.e first in the list. I want to get Counties of different States with the help of a QueryString. Where I have to give this QueryString to get the Data for Different State's Counties
I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
U can select using DataTabale.Select Method DataTable dt=ds.table[0]; datarow[] dr=dt.select("State='"+var+"'"); Best Regard Pathan
---------------------------------------------------
-
where i stored CountyName in ss string. u store all CountyName in hash table or collection then bind drop down list(out side the for each)
Piyush Vardhan Singh Programmer TAS NewDelhi India
Thank u for u r reply Piyush Vardhan Singh But I am having all the County Names of different States in a single XML file. How can I get County Names of each State in order to bind that Data to ListBox. As I said earlier I getting that State Name in a QueryString, with that Name in the QueryString I have to get the Couty Names of that State. How can I make this kind of selection.
I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
-
U can select using DataTabale.Select Method DataTable dt=ds.table[0]; datarow[] dr=dt.select("State='"+var+"'"); Best Regard Pathan
---------------------------------------------------
-
Ok How can I use this in your given code.
I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison Thank u Chandu
DataSet ds=xdoc.dataset; DataTable dt=ds.table[0]; DataRow[] dr=dt.select("State='"+statename+"'"); DataTable dt1=new DataTable(); foreach(DataRow dr1 in dr) { dt1.Rows.Add(dr1) } ddl.DataSource=dt1; ddl.DataTextField="CountryName"; ddl.databind();
Best Regard Pathan---------------------------------------------------