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  |  

PortalWebHosting
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
WebHostForAsp.net
 


  Sponsors  

Meet Our Sponsors

Click here to go to dev.live.com for Windows Live developer resources
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
The Official Microsoft ASP.NET Website
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! (Pro...  Converting comma separated values from string to integer with Linq
Previous Previous
 
Next Next
New Post 5/7/2008 12:49 PM
Unresolved
User is offline toadkicker
19 posts
10th Ranked


Converting comma separated values from string to integer with Linq 

Hello DNN community,

I'll try to keep things generic so others can apply this to their situtations.

I have a CheckBoxList control that is databound to a LinqDataSource. TableA is like this:

ID | Name

1 | Paul

2 | Bill

and so on....

Table B is

ModuleID | LoadTypes

1032 | 1,2

The index values from the checkboxlist are equal to the ID's from the table. I then have to store these values in TableB as a CSV list. So I do the following:

            Dim strListItemIDs As String = ""
            For Each li In chkListTypes.Items
                If li.Selected Then
                    strListItemIDs += li.Value & ","
                End If
            Next

(Yes I trim the comma off later on)

So where I am stuck is on the return trip to this page the check boxes need to be selected from this CSV list of values. I get that I need to do

Dim types = From loadedTypes In db.TableB Where loadedTypes.moduleID.Equals(ModuleId) Select loadedTypes.loadtype.Split(",")

which produces a string type of each value in TableB.LoadTypes. So now I would have a for loop for ChkBox.Items(types).Selected = True. But how do I convert my variable 'types' from the string to an integer?

 

 
New Post 5/9/2008 3:30 PM
User is offline toadkicker
19 posts
10th Ranked


Re: Converting comma separated values from string to integer with Linq 

Guess I have no takers?

Here it is for anyone else needing help

        Protected Sub chkListTypes_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles chkListTypes.PreRender
            Dim db As New DirectoryDataContext
            Dim Mytypes = From loadedTypes In db.TGIDirectorySettings Where loadedTypes.moduleID.Equals(ModuleId) Select loadedTypes.loadtype
            Dim items = Mytypes.Single.Split(",")
            For i As Integer = Mytypes.Count To 0 Step -1
                For Each item As String In items
                    chkListTypes.Items.FindByValue(item).Selected = True
                Next
            Next i
        End Sub

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! (Pro...  Converting comma separated values from string to integer with Linq
 


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.

 


DotNetNuke Web Hosting w/ ASP.NET 3.5
Unlimited email boxes, Unlimited databases, Unlimited domains. Plans start at $4.97
www.MyWinHosting.com
SteadyRain
Founded in 1999, SteadyRain has extensive experience delivering Internet technology strategies and solutions for a diverse client base, ranging from Fortune 500 firms to successful start-ups.
www.steadyrain.com
AfterImage Internet Consulting and SEO Services
AfterImage provides search engine optimization (SEO), Internet consulting and hosting services for the Windows platform (IIS, ASP, SQL Server).
www.afterimage.nl/

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