Solved

Search interface with Gridview results and AJAX

Posted on 2007-04-11
6
447 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now