sitemappath is not showing sub categories...
-
Hello friends, I am developing a shopping cart. I need a sitemappath in this. I implemented the code but the problem is that I have a categories table from which the sitemappath is fetching the data. In these categories some are main categories and some are their sub categories. For Example I am having a category structure like this: Glassware>>Beer Glass>>Universal Beer Glass... When I click on glassware, my sitemap shows like this: Home:Glassware Then after that when I click on Beer Glass, the sitemappath disappears. ie the sitemappath is shown till I have one sub-level. I did like this: Please assist me....
public void GenerateXMLFile(string sFileName) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString); SqlCommand cmd = new SqlCommand("select \* from CATEGORY ", con); //SqlCommand cmd1 = new SqlCommand("select \* from PRODUCTS ",con); cmd.Connection.Open(); //cmd1.Connection.Open(); SqlDataReader reader1 = cmd.ExecuteReader(); //Create XML Encoding enc = Encoding.UTF8; XmlTextWriter objXMLTW = new XmlTextWriter(sFileName, enc); try { objXMLTW.WriteStartDocument();//xml document open //'Top level (Parent element) //root node open objXMLTW.WriteStartElement("siteMap"); //first Node of the Menu open objXMLTW.WriteStartElement("siteMapNode"); //Title attribute set objXMLTW.WriteAttributeString("title", "Home"); objXMLTW.WriteAttributeString("description", "This is home");//Description attribute set objXMLTW.WriteAttributeString("url", "~/index.aspx");//URL attribute set //Loop and create nodes while (reader1.Read()) { int MasterID = reader1.GetInt32(0); objXMLTW.WriteStartElement("siteMapNode"); objXMLTW.WriteAttributeString("title", reader1.GetString(1)); objXMLTW.WriteAttributeString("description", reader1.GetString(5)); objXMLTW.WriteAttributeString("url", reader1.GetString(11)); objXMLTW.WriteEndElement();//Close the siteMapNode } objXMLTW.WriteEndElement();//Close the first siteMapNode objXMLTW.WriteEndDocument();//xml document closed } finally {
-
Hello friends, I am developing a shopping cart. I need a sitemappath in this. I implemented the code but the problem is that I have a categories table from which the sitemappath is fetching the data. In these categories some are main categories and some are their sub categories. For Example I am having a category structure like this: Glassware>>Beer Glass>>Universal Beer Glass... When I click on glassware, my sitemap shows like this: Home:Glassware Then after that when I click on Beer Glass, the sitemappath disappears. ie the sitemappath is shown till I have one sub-level. I did like this: Please assist me....
public void GenerateXMLFile(string sFileName) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString); SqlCommand cmd = new SqlCommand("select \* from CATEGORY ", con); //SqlCommand cmd1 = new SqlCommand("select \* from PRODUCTS ",con); cmd.Connection.Open(); //cmd1.Connection.Open(); SqlDataReader reader1 = cmd.ExecuteReader(); //Create XML Encoding enc = Encoding.UTF8; XmlTextWriter objXMLTW = new XmlTextWriter(sFileName, enc); try { objXMLTW.WriteStartDocument();//xml document open //'Top level (Parent element) //root node open objXMLTW.WriteStartElement("siteMap"); //first Node of the Menu open objXMLTW.WriteStartElement("siteMapNode"); //Title attribute set objXMLTW.WriteAttributeString("title", "Home"); objXMLTW.WriteAttributeString("description", "This is home");//Description attribute set objXMLTW.WriteAttributeString("url", "~/index.aspx");//URL attribute set //Loop and create nodes while (reader1.Read()) { int MasterID = reader1.GetInt32(0); objXMLTW.WriteStartElement("siteMapNode"); objXMLTW.WriteAttributeString("title", reader1.GetString(1)); objXMLTW.WriteAttributeString("description", reader1.GetString(5)); objXMLTW.WriteAttributeString("url", reader1.GetString(11)); objXMLTW.WriteEndElement();//Close the siteMapNode } objXMLTW.WriteEndElement();//Close the first siteMapNode objXMLTW.WriteEndDocument();//xml document closed } finally {
Sneha ji, Bottom-Top approach is needed in such scenerio