Obtaining name of categories from database
Hello!
I need to obtain all the categories names of news to put them in a list of a custom widget. I have tried to use the class CustomManager as I saw in www.sitefinity.com/.../categories-get.html So I did this:
ContentManager content = new ContentManager(); protected void Page_Load(object sender, EventArgs e) Guid cod = new Guid(LoadCode()); ContentItem query = content.GetContent(cod); public string LoadCode() string result = ""; path = Directory.GetCurrentDirectory().ToString() + "/Projects/sqlEmdse/App_Data/Sitefinity/Configuration/DataConfig.config"; XDocument doc = XDocument.Load(path); var smt = from nodes in doc.Descendants("connectionStrings") select new label = nodes.Element("add").Attribute("connectionString").Value, ; foreach (var value in smt) conString = value.label; SqlConnection conn = new SqlConnection(conString); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT val FROM sf_news_items_category", conn); result = cmd.ExecuteScalar().ToString(); conn.Close(); return result; ContentItem query = content.GetContent(cod);" because of a null reference. So I can´t use the existed GUID in "sf_news_items_category" table because it has no ContentItem asociated? If yes, How can I get the name of my categories by coding?