Newbie: How to display search results?

Discussion in 'ASP .Net' started by JM, Jul 10, 2006.

  1. JM

    JM Guest

    I am new to ASP.NET, so probably my question is very basic:

    I have a web page (page1) where I allow the user to make a search, text box
    plus a botton (botton1).
    When he click the botton (button1), the server obtain (from memory) an array
    of Products Id.
    I want to open a second web page (page 2) with the results (obtained from a
    database using the Products Id), the results will be shown in a datagrid.

    My question:
    - If Once I clicked botton1 I retrieve from de database the Products (using
    the array of ProductsId and a datareader) how I bound this datareader to the
    datagrid in page2?.
    - I think there is a second option: I pass the array (memory array) of
    products Id to Page2 (how i do it?) and the Onload event of Page2 read the
    data from the database and show it in the datagrid. How I pass the memory
    array to Onload event of Page2?.

    I am pretty new to ASP.NET so I suspect there is an standard way of doing
    this, I welcome any suggestion.

    Thanks,

    Jaime
     
    JM, Jul 10, 2006
    #1
    1. Advertising

  2. JM

    Hans Kesting Guest

    > I am new to ASP.NET, so probably my question is very basic:
    >
    > I have a web page (page1) where I allow the user to make a search, text box
    > plus a botton (botton1).
    > When he click the botton (button1), the server obtain (from memory) an array
    > of Products Id.
    > I want to open a second web page (page 2) with the results (obtained from a
    > database using the Products Id), the results will be shown in a datagrid.
    >


    By "open a second page", do you mean "open in a new window", or just
    "replace the current page"? If new window, then see if there is a
    "target" attribute on that button (button1). If current page, then
    nothing special needs to be done.

    > My question:
    > - If Once I clicked botton1 I retrieve from de database the Products (using
    > the array of ProductsId and a datareader) how I bound this datareader to the
    > datagrid in page2?.
    > - I think there is a second option: I pass the array (memory array) of
    > products Id to Page2 (how i do it?) and the Onload event of Page2 read the
    > data from the database and show it in the datagrid. How I pass the memory
    > array to Onload event of Page2?.
    >
    > I am pretty new to ASP.NET so I suspect there is an standard way of doing
    > this, I welcome any suggestion.
    >
    > Thanks,
    >
    > Jaime


    To switch from one page to another, you can use "Response.Redirect()",
    using the new url as a parameter.

    To pass data from one page to another, there are several options:
    - querystring, like "page2.aspx?searchtext=bla". Best for a small list
    of short values, that can be represented by a string.
    - Session data. In page1 you store "it" in the session
    (Session["productids"] = list) and in page2 you read it, casting as
    required ( int[] list = (int[])Session["productids"] )

    You can perform the search in page1, passing the results (via Session)
    to page2. Or you can pass the searchtext to page2 (session or
    querystring), where the complete search is performed. I like the second
    option better, as you concentrate the "search functionality" in that
    page.

    Hans Kesting
     
    Hans Kesting, Jul 10, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Monique Y. Mudama
    Replies:
    1
    Views:
    462
    Monique Y. Mudama
    Jun 28, 2005
  2. Mike M
    Replies:
    0
    Views:
    659
    Mike M
    Nov 16, 2007
  3. Abby Lee
    Replies:
    5
    Views:
    443
    Abby Lee
    Aug 2, 2004
  4. JP SIngh

    Search two tables and display results

    JP SIngh, Jan 18, 2006, in forum: ASP General
    Replies:
    2
    Views:
    149
  5. Craig Keightley
    Replies:
    10
    Views:
    272
    Craig Keightley
    Jun 29, 2005
Loading...

Share This Page