Newbie: How to display search results?

J

JM

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
 
H

Hans Kesting

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top