How to filter the following lists in asp.net?

I have 4 lists (lstStates, lstCounties, lstCities and lstZipcodes). There are some limitations:

  • None of the lists are disabled.

  • Any list can be selected at any time, that is, there is no specific order that the user must select.

  • Filtering - forward and backward. By this I mean that if the user selects a state from lstStates, it will filter lstCounties, lstCities and lstZipcodes. If user selects zipcode from lstZipcodes, he will filter lstCities, lstCounties and lstStates.

  • The list allows several options to be allowed.

Each listbox is bound to a datatable to retrieve its source data. This information is retrieved from the sqlserver stored procedure. Each list has its own stored procedure, for example, lstStates has one called GetStates that returns one column (State), and ListBoxes DataValueField and DataTextField are both set to State. Like lstStates, lstCities is bound to a datatable, which gets one column from the GetCities stored procedure, which is a city.

Another thing I want to point out is that I am connecting an ObjectDataSource to receive data.

0


source to share


3 answers


Already asked the question: What is the most efficient way to filter lists based on selection of another in C #?

[edit] Well, what you need to do is add an event to every [myListbox] _SelectedIndexChanged event. When the selection is changed, you will need to update all other lists based on those selections. My guess is that this will need to be handled with the database as binding states to ZipCodes in some other way would be ugly. So presumably your data for the States ↔ Zips ↔ Counties relationship is somewhere in your db.



So you will need procs in your db (or LINQ middle layer) that will get states by Zips, etc. On each event-modified event, send the new selection back to the db sproc and then rearrange the list based on the returned data. You should be able to make one sproc for each one that returns all states if no zip was passed and so on. [/ Edit]

+2


source


To clarify, on initial page load, are you downloading ALL zipcodes, ALL cities, ALL states and ALL countries?



This seems a little cumbersome to me. This is a question that I would question. (Of course, I don’t know that you didn’t ask about this already or that he had a good answer).

0


source


ScriptManager.RegisterStartupScript (Page, Page.GetType (), "bab", "CacheItems ();", true);

  var ddlText, ddlValue, ddl, lblMesg; function CacheItems () {ddlText = new Array (); ddlValue = new Array (); ddl = document.getElementById (""); for (var i = 0; i
0


source







All Articles