Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In CheckBoxList pass multiple values from one page to another page...
Posted

you can use session for this
In first page set session
C#
// 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
C#
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!
:)
 
Share this answer
 
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! :)
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
 
Share this answer
 
v2
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.
XML
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900