Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:49:18+00:00 2026-06-08T21:49:18+00:00

I am trying to pass the selected items from a checkboxlist in asp.net (vs

  • 0

I am trying to pass the selected items from a checkboxlist in asp.net (vs 2005/.net 2.0) as a concatenated string.

Currently my .aspx is

        <asp:CheckBoxList id="checkbox1" AutoPostBack="False" AppendDataBoundItems="true" CellPadding="5" CellSpacing="5" RepeatColumns="1" RepeatDirection="Vertical" RepeatLayout="Flow" TextAlign="Right" runat="server">
            <asp:ListItem Value="1">Carrots</asp:ListItem>
            <asp:ListItem Value="2">Lettuce</asp:ListItem>
            <asp:ListItem Value="3">Olives</asp:ListItem>
            <asp:ListItem Value="4">Onions</asp:ListItem>
            <asp:ListItem Value="5">Tomato</asp:ListItem>
            <asp:ListItem Value="6">Pickles</asp:ListItem>
        </asp:CheckBoxList>

And the .aspx.vb is (inside the Protected Sub for submit)

    For Each li As ListItem In checkbox1.Items
        If li.Selected = True Then
            checkbox1.Text = checkbox1.Text + "," + li.Text
        End If
    Next

Which is written to the db via

checkbox1.Text = dv(0)("Salad").ToString()

When I select and save, I am currently getting an error

Server Error in ‘/’ Application.

‘checkbox1’ has a SelectedValue which is invalid because it does not exist in the list of items.

Parameter name: value

Any thoughts on how to concatenate the selected checkbox items

For example, if some selects Carrots, Lettuce, and Tomato;

checkbox1 = 1,2,5
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:49:20+00:00Added an answer on June 8, 2026 at 9:49 pm

    I don’t think you are assigning to a variable like you describe you are returning.

    string list = "";
    For Each li As ListItem In chkQ4.Items
            If li.Selected = True Then
                list = list + "," + li.Text
            End If
        Next
    

    is how you should write the line above.

    In C# using linq, I would write

    var list =  checkbox1.Items
    .Cast<ListItem>()
    .Where(item => item.Selected == true)
    .Select(item => item.Value);
    var result = string.Join(",",list);
    

    which I believe is the following in VB

    Dim list = checkbox1.Items.Cast(Of ListItem)().Where(Function(item) item.Selected = True).[Select](Function(item) item.Value)
    Dim result = String.Join(",", list.ToArray())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the value user selected from search prompt and pass
I am trying to get the trail name from the selected cell and pass
I am trying to pass a selected value from a combo box that is
I am trying to pass a selected checkbox value from one page to another
I'm trying to pass through three variables ( artistID , albumID and currently selected
seems like I'm stuck with jQuery tabs. I'm trying to pass selected tab name
Trying to pass in a user supplied string which has a path to the
Trying to pass a string argument to a function, which will then be used
I am trying to pass a string over to a detail view of my
I am trying to pass values of selected checkboxes to a PHP file using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.