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

  • SEARCH
  • Home
  • 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 6612791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:08:25+00:00 2026-05-25T20:08:25+00:00

I am writing a web site in Visual Studio, something like an on-line library.

  • 0

I am writing a web site in Visual Studio, something like an on-line library. I have a GridView on the first page that presents all of the books available from the data source and some other properties also contained in the data source. The GridView contains check boxes and the user can choose which books he wants to order by checking a box. My question is how can I use the data in the selected rows, the list of books with their properties and show that list on another page, so that the user is able to know which items he has selected?

I tried with a for loop on the FirstPage:

  for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                int bookID = (int)GridView1.DataKeys[i][0];
                CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
                if (cb.Checked)
                {
                    purchaseProductList.Add(bookID);
                    Response.Redirect("SecondPage.aspx?bookID" + i + "=" + bookID); 
                }
       }

and then on the SecondPage:

for (int i = 0; i < 10; i++)
{
    if (Request.QueryString["bookID" + i] != null)
    {
        DataRow row;
        row = dtBooks.NewRow();
        row["ID"] = Request.QueryString["bookID" + i];
        dtBooks.Rows.Add(row);
    }
}
GridView1.DataSource = dtBooks;
GridView1.DataBind();

but it didn’t work. Any help? Thank you in advance.

  • 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-05-25T20:08:26+00:00Added an answer on May 25, 2026 at 8:08 pm

    you can use session to keep selected ids

    List<string> ids = new List<string>();
    for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    int bookID = (int)GridView1.DataKeys[i][0];
                    CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox");
                    if (cb.Checked)
                    {
                        purchaseProductList.Add(bookID);
                        ids.Add(bookID);
                    }
           }
    
    Session["Ids"] = ids;
    
    Response.Redirect("SecondPage.aspx"); 
    

    from second page you can access session and load those ids to grid

    var list = (List<string>)Session["Ids"];
    
    foreach (string id in list)
    {
    
      DataRow row;
      row = dtBooks.NewRow();
      row["ID"] = Request.QueryString["bookID" + id];
      dtBooks.Rows.Add(row);
    }
    GridView1.DataSource = dtBooks;
    GridView1.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m writing a web site targeted at the iPhone. I’d like to set a
I am writing code to performance test a web site. I have the following
I'm writing my first C# web application that connects to an XML based service.
I have a legacy web-site that I am maintaining (built mostly in classic ASP
I'm writing a web site that uses multiple web services with throttle restrictions. I.e.
I'm writing a web site (ASP.NET/C#) that is specifically targeted at mobile phones. On
I am writing a basic wizard for my web site. It will have 4
I am writing a website with Visual Studio 2008 and ASP.NET 3.5. I have
I writing a web site that uses Active Directory to validate users. I don't
I'm writing an application updater that pulls installation package from our distribution web site

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.