Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

telerik
ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Configure It! (...  Populate a listbox control from a database - help....please
Previous Previous
 
Next Next
New Post 3/19/2008 12:08 AM
User is offline Brad Bates
5 posts
10th Ranked


Populate a listbox control from a database - help....please 

Hi,

I'm working on a DNN module that requires uses to select a number of options from a listbox control. Once the user makes their selections within the listbox control, the data is stored in a database. My challenge is that if a user want's to edit their listbox selections, I don't know how to populate the listbox items from a database indicating which items were selected. Here's the code that I have so far:

 

Dim objPC As New ProjectControllerDim arrPc As ArrayList = objPC.GetProjectsCategories(ProjectId)

 

Dim Item As String

 

 

 

For Each Item In arrPcDim currentCheckBox As ListItem = ChkLstProjectCategories.Items.FindByValue(Item("ProjectCategoryId").ToString())If currentCheckBox IsNot Nothing Then

currentCheckBox.Selected =

True

 

End If

 

Next

 

End Sub

Can anyone see what I'm doing wrong here? Do you have some code to share that would help me get this to work?

Many thx

Brad

 

 
New Post 12/4/2008 4:04 PM
User is offline Beanie
72 posts
10th Ranked


Re: Populate a listbox control from a database - help....please 

Hope this helps.

To select an item for a listbox do the following:

Populate the listbox as you normally would.

After populating try the following, to which you'll need to supply the listbox name as indicated by yourListBoxIDhere

yourListBoxIdHere.SelectedItem = yourListBoxIdHere.Items.IndexOf(yourListBoxIdHere.Items.FindByValue("WhatYouAreLookingFor"))

The only thing I don't know is how to get it to select multiple values, should you allow that. Also, most likely WhatYouAreLookingFor is probably going to be an int or Integer since you might have it as an index value of some sort from your database.

Hope that helps.

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Configure It! (...  Populate a listbox control from a database - help....please
 


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.

 


SINA101
WANT A SPECial sIte iN TAIWAN?
sina101.com
Web Development and Strategy Firm
The Risdall Interactive Agency s websites, strategies, branding, & promotion in digital space.
www.Risdall.net/
Windsor Management Group
Fund Accounting Software for K12 Education.
Infinitevisions.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP