Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow to fill DnnComboBox with data?How to fill DnnComboBox with data?
Previous
 
Next
New Post
5/26/2013 11:09 AM
 
Hi all,

in a module I want to use a DnnComboBox (DotNetNuke.Web.UI.WebControls.DnnComboBox). To fill it with data, I did the following:

(ascx:)
<dnn:DnnComboBox ID="myComboBox" runat="server" />

(c#:)
StringBuilder items = new StringBuilder();
items.Append("<Items>");
items.Append("<Item Text=\"A\" Value=\"1\" />");
items.Append("<Item Text=\"B\" Value=\"2\" />");
items.Append("<Item Text=\"C\" Value=\"3\" />");
items.Append("</Items>");
this.myComboBox.LoadXml(items.ToString());

(The reason for StringBuilder is that I want to fill data from a database at a later stage).

When running the code I get a System.InvalidOperationException, message: "Error in XML document (1,2)".
The inner exception reads: "Message=<Items xmlns=''> was not expected."

I also tried to start with
items.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");

This changed the error message to "Error in XML document (1,41)", so it is obviously not important.

Can anybody tell me what this means and how to do it correctly?

Best wishes
Michael

Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/26/2013 12:25 PM
 
Hi Michael,

The DnnComboBox is a wrapper of the RadComboBox... and the RadComboBox won't let you do that the way you're trying. Fortunately, it's a pretty easy fix.

You have many ways you can bind data in the box... I'd look here for general examples: http://demos.telerik.com/aspnet-ajax/... and for help on specifics, go here: http://www.telerik.com/help/aspnet-aj...

In the meantime, to do what you want to do there, you can just add items manually to the combo box item. To do that, in code just use this line:

myComboBox.Items.Add(New DnnComboBoxItem("Text","Value")) - that's the VB code

It sounds like, in your scenario, you may want to combine data-source binding with manually added items... That's common - just use the "AppendDataBoundItems" option to make it possible.

Hope this helps,

Mike
 
New Post
5/27/2013 2:51 AM
 
Mike,

it is a bit more complex (or it should be at the end...). What I want is more like this example:

http://demos.telerik.com/aspnet-ajax/...

and I am trying to bind data from an XML string, like here:

http://demos.telerik.com/aspnet-ajax/...

The problem is, I get this error even when I am trying this code with an XML file - which at the end should be a generated XML string that contains the tree like


<Items>
   <Item value="1" text="A">
      <Items>
      <Item value="11" text="A1">
      <Item value="12" text="A2">
         <Items>
            <Item value="111" text="A1.1">
            <Item value="112" text="A1.2">
            <Item value="113" text="A1.3">
         </Items>
      </Item>
      <Item value="13" text="A3">
   </Item>
   <Item value="2" text="B" />
   <Item value="3" text="C" />
</Item>

Any idea?

Best wishes
Michael

Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/27/2013 5:07 AM
 
Hi again,

what I found out in the meantime: I tried to use the telerik:RadComboBox instead of the DnnCombobox, and the thing works with an XML file, but as soon as I change the control to the wrapper, I get this error. Is it possible that there is some error in the wrapper?

Anyway, if I try to use the string instead of the XML file, the error is there with the RadComboBox as well.

I tried to follow this example:
http://www.telerik.com/community/foru...

Best wishes
Michael

Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
5/27/2013 10:07 AM
 
Solved... Adding the TreeNodes programatically works...

Only one more question: I did not find such thing as a DnnTreeNode that corresponds to Telerik.Web.UI.RadTreeNode. Is it OK to use Telerik.Web.UI.RadTreeNode in the code-behind?

DnnTreeView tree = (DnnTreeView)myComboBox1.Items[0].FindControl("myTreeView");
Telerik.Web.UI.RadTreeNode node = new Telerik.Web.UI.RadTreeNode("A", "1");
node.Expanded = true;
tree.Nodes.Add(node);

Best wishes
Michael

Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesHow to fill DnnComboBox with data?How to fill DnnComboBox with data?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out