Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Search interface with Gridview results and AJAX

Posted on 2007-04-11
6
Medium Priority
?
489 Views
Last Modified: 2008-01-09
Ok, here's what I want to do, I just need some direction in starting to understand how I may approach this with "good code" in mind:

I have a page, and in it, I have some dropdowns at the top.  At the bottom of the list of dropdowns is a Search Button.

 I want to show a list of records obtained by whatever search logic I encorporate into a GridView.

 Furthermore, I plan on wrapping the GridView control into an ASP.NET AJAX updatepanel with the hopes that I do not get a page refresh.

 I need to first understand how I'd get the search criteria's list results to the same page's GridView, below the search parameter dropdown boxes.
0
Comment
Question by:dba123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
jasco4617 earned 2000 total points
ID: 18891663
Lets say, you have a simple select statement as you search logic, something like this:  SELECT * FROM table WHERE column = @dropdownlistvalue

@dropdownlistvalue would be an asp:controlparameter for your datasource and it woudl be set to the SelectedValue of your dropdownlist.  That way, each time the datasource's databind event is called, it will insert what ever value is selected into you query.

You could use the same principle if you where to use some programming logic instead of a simple query.  In your procedure you could use a switch statement that looks at the selected value of the dropdownlist and the performs a certain type of logic.

- Pat
0
 
LVL 1

Author Comment

by:dba123
ID: 18891701
Yea, I understand that...thanks.  What I'm more concerned with is how the gridview is to be setup and to work once the user clicks search and it binds to the grid to update the list of records retreived
0
 
LVL 1

Author Comment

by:dba123
ID: 18891708
I mean, I have the gridview on my page, now, just need to figure out the backend workings.  I want the gridview to refresh once th euser clicks SEARCH.  Ok, but hmm....how to go about doing this...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Assisted Solution

by:jasco4617
jasco4617 earned 2000 total points
ID: 18891775
on you search button include this attribute OnClick="Search_Click"

and in your code, include this procedure:

protected void Search_Click(object sender, EventArgs e) {
    GridView1.DataBind();
}


This is assuming you are C# and that the name of your gridview is GridView1 (the default name).   basically what this will do, is rebind the gridview.

If you wish decide you need to redo the search logic before you call databind(), then you would simply execute that logic before you call DataBind().

The logic you use for the search will need to return a set of data in some form (dataset, datatable, multi-dimensional array, etc...) and the way you would assign that set of data to the datagrid is by calling "GridView1.Datasource = yourdatasource" and that would be done before calling DataBind().

I hope that answers your question.

- Pat
0
 
LVL 1

Author Comment

by:dba123
ID: 18891793
I kinda see what you'r esaying now.  

User clicks Search
All the asp:controlparameter would pass the values to my underlying stored proc.  Since the user clicked Search, in the search onclick I'd do the databind...
0
 
LVL 4

Expert Comment

by:jasco4617
ID: 18891815
Correct.

After the user clicks submit, the gridview would fire the databind procedure, which would then fire the databind procedure for the datasource, which would then pull the selected value from the dropdownlist and then pass it store proc.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question