Solved

Search interface with Gridview results and AJAX

Posted on 2007-04-11
6
487 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Assisted Solution

by:jasco4617
jasco4617 earned 500 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

624 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