SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jun 16, 2009, 10:55 #1
- Join Date
- Apr 2004
- Location
- canada
- Posts
- 274
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Two Droplists bound to gridview and DB
I am trying to find a tutorial on cascading droplists that work like this:
1) State droplist is bound to DB and pulls all evident states in DB
2) City droplist dynamically fills based on the value of the State droplist and shows all cities in the DB
3) Gridview will then dynamically filter the data based on the State and City value and show the end user the data.
I have not been able to find a tutorial that deals with TWO droplists.
Can someone please lead me in the right direction?
THANKS!!
-
Jun 16, 2009, 11:24 #2
- Join Date
- Aug 2007
- Location
- Pennsyltucky
- Posts
- 1,494
- Mentioned
- 3 Post(s)
- Tagged
- 0 Thread(s)
Something like this?
http://www.asp.net/AJAX/AjaxControlT...gDropDown.aspx
-
Jun 16, 2009, 11:29 #3
- Join Date
- Apr 2004
- Location
- canada
- Posts
- 274
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi NAWA-mark, I did see that site but it lacks the gridview function with filtering based on the two values. I'm not sure if I'm able enough to adapt it.
Any ideas on how to implement the gridview?
Thanks!!
-
Jun 16, 2009, 11:46 #4
- Join Date
- Aug 2007
- Location
- Pennsyltucky
- Posts
- 1,494
- Mentioned
- 3 Post(s)
- Tagged
- 0 Thread(s)
bind the gridview to a deferred linq operator (select) and then run the filters at the postback
I did something similar with a listview on a simple blog system that would allow you to filter based on category:
Code Csharp:using (var dbc = new siteDataContext()) { var blogPosts = pageItems.blogPosts(dbc); HttpCookie catSelect = new HttpCookie("category"); // if a category is selected filter the results if (categoryDropDown.Text != "0") { catSelect["catName"] = categoryDropDown.Text; blogPosts = from p in blogPosts where p.categoryID == Convert.ToInt32(categoryDropDown.Text) select p; } else { catSelect["catName"] = "0"; } Response.Cookies.Add(catSelect); // blogs is my listview blogs.DataSource = blogPosts.ToList(); blogs.DataBind(); }
Using your plan you can filter at the state dropdown and the city dropdown or just wait for the selection on the city dropdown.
-
Jun 17, 2009, 10:15 #5
- Join Date
- Aug 2007
- Location
- Pennsyltucky
- Posts
- 1,494
- Mentioned
- 3 Post(s)
- Tagged
- 0 Thread(s)
Sooooo. What'd you come up with?
-
Jun 17, 2009, 10:35 #6
- Join Date
- Apr 2004
- Location
- canada
- Posts
- 274
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey Nawa-Mark, your suggestion was a little beyond my capability. I think what you are suggesting is better because of the ajax element.
I ended up creating a datasource. The 2nd droplist is bound to the first and the gridview to display that correct data is bound to the value of both droplists. I wrapped everything in an update panel to bypass the auto-post screen flash. It works fine, but I'm not in love with it.
I would like to bind the droplists to a button, when clicked the gridview is updated, I haven't started this step yet, and not sure if I'll be able to get it to work, but I will try.
Thanks for your help!! It did lead me in the right direction.
Bookmarks