Solved

Search interface with Gridview results and AJAX

Posted on 2007-04-11
6
472 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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