Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
In CheckBoxList pass multiple values from one page to another page...
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 2

you can use session for this
In first page set session
// Create the list to store.
        List<string> StrList = new List<string>();
        // Loop through each item.
        foreach (ListItem item in ChkBox.Items)
        {
            if (item.Selected)
            {
                // If the item is selected, add the value to the list.
                StrList.Add(item.Value);
            }
        }
// Now set session 
session["selectedStrList"] = StrList;
//Redirect to other page
Response.Redirect("...", false);

then recieve list from session in second page's page load event
if(!IsPostBack)
{
    List<string> StrList = new List<string>();
    if ( session["selectedStrList"] != null) //confirm session is not null
         StrList = (List<string>)session["selectedStrList"]; //cast session object to list of string
}

Happy Coding!
:)
   
v4
Comments
Gokul Athithan 30-Dec-13 6:53am
   
I am getting this error when i write this code
if (!IsPostBack)
{
List<string> strlist=new List<string>();
strlist=Session["sele"];
}
Cannot implicitly convert type 'object' to 'System.Collections.Generic.List<string>'. An explicit conversion exists (are you missing a cast?)
Aarti Meswania 30-Dec-13 7:22am
   
I have updated solution
please check again
hope this will work perfectly as your requirement :)
Gokul Athithan 30-Dec-13 7:49am
   
Thank You...
Aarti Meswania 30-Dec-13 8:19am
   
Welcome!
Glad to help you! :)
Rate this:
Please Sign up or sign in to vote.

Solution 1

you have create one hidden field then create array and when any checkbox is cheked then push it to in array when form submit then array strore in hidden field and pass to another page
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

You need to ask specific question with details to get help. It's not possible to know exactly what you are trying to do.

Anyway, this is the ASP (server side) control you are using. The values get passed to the next page on form submit, without you doing anything.
for this control

<asp:CheckBoxList ID="CheckBoxList1" runat="server" ClientIDMode="Static">
            <asp:ListItem Text="1" Value="1" />
            <asp:ListItem Text="2" Value="2" />
        </asp:CheckBoxList>



Just access them as

CheckBoxList1.Items(i).Selected
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100