How to pass the checkbox list value from one page to another


hi,
 I have a checkboxlist ,which has its databound from SQL dabase.I am using this checkboxlist in administrator page.So that when a checkbox in the checkboxlist is clicked I would like to pass this value to another page in which I enable a function(For example I enable a Button if the checkboxlist is checked else the button is disabled).
  I tried to pass this value(the checkboxlist selected value) using a session but I dont know how to do this exactly as I am new to ASP.net and C#.
 I am trying with the code below .Can you help me how I can achieve this




The code in the Administrator page
code in aspx.cs 

 protected void Page_Load(object sender, EventArgs e)
        {           
                if (Session["Sel_Inst"] != null)
                    Label2.Text = Session["Sel_Inst"].ToString();
         }

 protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label1.Text = string.Empty;
            foreach (ListItem listitem in CheckBoxList1.Items) { 
                if (listitem.Selected) 
                    Label1.Text += listitem.Value + "<br />";
            }
            Session["Sel_Inst"] = Convert.ToString(Label1.Text);
        }


code in aspx 

<asp:CheckBoxList 
            ID="CheckBoxList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" 
            DataTextField="Institution_name" DataValueField="Institution_no" 
            onselectedindexchanged="CheckBoxList1_SelectedIndexChanged" >
        </asp:CheckBoxList>

Open in new window



The code in the page where I would like to pass the value from the Administrator page

 protected void Page_Load(object sender, EventArgs e)
        {
            string En_Resub;
            if (Session["Sel_Inst"] != null)
             En_Resub = Session["Sel_Inst"].ToString();
        }

Open in new window

asudhaaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
Hmm.  I think your best approach would be to commit the data back to the SQL database, then use the committed values to dis/enable the buttons on the second page.

If you don't want to do that, you can store the checkbox values (both checked and unchecked) in an array, stuff that into your session variable, then parse the array on the second page to dis/enable the buttons.
0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,
you can use a hiddenfield and with Postbackurl feature with PreviousPage, or you can also use querystring

for more details refer to
http://www.dotnetheaven.com/UploadFile/prathore/PostBack05032007005048AM/PostBack.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.