HomeHomeDevelopment and...Development and...DotNetNuke Open...DotNetNuke Open...State List for moduleState List for module
Previous
 
Next
New Post
2/15/2012 11:51 AM
 

I'm making a module and I'm trying to populate a combobox from code from here:

http://www.dotnetnuke.com/Resources/F...

Unfortunately it appears to be obsolete. I can't figure out how to get updated code that works.

Right now I'm using this:

Dim lc As New ListController()
Dim entryCollection As ListEntryInfo = lc.GetListEntryInfo("Region", "221")
cmbForwardState.DataTextField = "Text"
cmbForwardState.DataValueField = "Value"
cmbForwardState.DataSource = entryCollection
cmbForwardState.DataBind()

When I run the page, it doesn't do anything. :(

 
New Post
2/15/2012 5:13 PM
 

Note that the GetListEntryInfo method returns only a single ListEntryInfo object, not a collection or list that can be bound to a drop-down list control.

Depending upon whether you are using DNN 5.x or 6.x you will want to use one of the following methods of the ListController to return a collection of ListEntryInfo items:

DNN 5.x - GetListEntryCollection which returns a custom ListEntryInfoCollection.

DNN 6.x - GetListEntryInfoItems which returns a generic IEnumerable<ListEntryInfo> collection.

You will then be able to bind the returned collection to the list control as you are now doing.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project
Extensions Forge Projects - UserExport, ContentDeJour, ePrayer and ImageEditorControl
 
New Post
2/22/2012 9:09 AM
 
I still can't seem to get it to work. This code crashes with:

DotNetNuke.Services.Exceptions.ModuleLoadException: Unable to cast object of type 'System.Collections.Generic.List`1[DotNetNuke.Common.Lists.ListEntryInfo]' to type 'DotNetNuke.Common.Lists.ListEntryInfo'. ---> System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[DotNetNuke.Common.Lists.ListEntryInfo]' to type 'DotNetNuke.Common.Lists.ListEntryInfo'.


Dim lc As New ListController()
Dim entry As DotNetNuke.Common.Lists.ListEntryInfo = lc.GetListEntryInfoItems("Region", "221")
 
New Post
2/22/2012 9:50 AM
 
Ahh got it! Here's the complete code to populate DNN 6 states list to a user control/module.

Dim lc As New DotNetNuke.Common.Lists.ListController()
Dim entryCollection As System.Collections.Generic.List(Of DotNetNuke.Common.Lists.ListEntryInfo)
entryCollection = lc.GetListEntryInfoItems("Region", "Country.US", 0)

With cmbForwardState
.DataTextField = "Text"
.DataValueField = "Value"
.DataSource = entryCollection
.DataBind()
End With
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DotNetNuke Open...DotNetNuke Open...State List for moduleState List for module


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me
Charlotte DoDNN

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Telerik JustCode Free
DotNetNuke DNN Hosting
Exact Target Exec Alert

DotNetNuke Scoop!

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.